After being seemingly inches from hitting a great approach shot on the 14th hole, Rory McIlroy found himself seconds away from losing the US Open on the final day. The 2011 champion frantically searched for his ball in the fescue above the bunker as a three-minute time limit for a lost-ball penalty approached.

Fortunately for McIlroy, he found his TaylorMade buried in the lip of the greenside trap. Even better? A rules official allowed him a free drop. Outside the bunker. Wait, what?

RELATED: You won’t believe where Cameron Young’s golf ball wound up

For golf fans confused as to why McIlroy got to move his ball without a penalty, the answer lies in the embedded golf ball rule. Here’s what the USGA’s website says in part: “This is an appropriate exception to the principle of playing the ball as it lies because having to play a ball that is stuck in soft or wet ground (whether in the fairway or the rough) should not be considered part of the normal challenge of playing a course.”

Now, there’s a huge caveat here. The ball can NOT be embedded in the sand. In that case, a player must play it as it lies or take an unplayable and add a penalty stroke. But it was (correctly) ruled that McIlroy’s ball was not in the sand, but above the bunker.

This is the same situation that happened to two contenders at last month’s PGA Championship, Viktor Hovland and Corey Conners. Both players hit fairway bunker shots that plugged in the lip on Oak Hill’s 16th hole and received free relief. However, it wasn’t enough to keep them in the tournament.

And this wasn’t enough to keep McIlroy from making bogey. The one club-length he was entitled to nearly got him back to the short grass, but he still had to drop in the rough. And was unable to get up and down, falling farther behind eventual winner Wyndham Clark.

In any event, it’s good to know the next time you play. Believe it or not, the rules can help you. Sometimes.