The Northern Irishman was approaching the famous green during the third round in the BMW PGA Championship.
Ten shots off the pace at four-under-par, McIlroy knew a strong iron shot on 18 could give him a chance at a precious eagle.
However, he was lucky to walk away with a par five.
That is because McIlroy’s second shot looked destined to land directly in the water in front of the green.
But in a seriously fortunate turn of events, rather than splashing into the brook, the golf ball ricocheted off the wooden sleeper and flew horizontally across the wet stuff and on to the safety of the dry grass.
The ball then fizzed across the back of the green and ended up in the rough – but crucially not in the greenside bunker in front of the grandstand.
McIlroy chipped over the back then back to within a couple of inches to tap in for the five.
But commentators and fans alike watching were stunned by the huge stroke of luck.
The crowd let out an almighty gasp before breaking into applause.
FREE BETS – BEST BETTING OFFERS AND BONUSES NEW CUSTOMERS
The Sky Sports commentator said: “Oh wow,” before bursting into laughter.
The DP World Tour shared the video on Twitter and wrote: “Rory McIlroy’s LUCKIEST shot ever…”
Another said: “Haters will say it was a fart, but it was Rory!”
A third added: “Rory 🙌🏽”
And a final user joked: “Well placed if you ask me. Top shot.”
The shot came just two holes after chipping in on the 16th for a birdie.
McIlroy only secured his place in the weekend’s action when he birdied on the 18th in the dark just before 7.30pm last night due to delays in the morning on day two.
The world No2 needed the aid of a giant scoreboard to act as a makeshift floodlight so he could see the hole amid chaotic scenes in Surrey.
McIlroy, who will be teeing it up at the Ryder Cup in two weeks, said: “It was a s***show.
“The fog obviously delayed things but I’ve never remembered having that many players on 17 and 18.
“It’s hard for me trying to play the last well and make the cut, it’s a bit of a mad dash and a scramble to get finished.”