Smith began the day four shots off the lead but his eight-under-par fourth round allowed him to finish a shot clear of Cameron Young of the United States, with a frustrated McIlroy ending another stroke back in third after a 70.
The world number six would have known something special was needed yesterday for him to win the Claret Jug and he duly delivered with eight birdies - including five in a row from the 10th - and not a single dropped shot.
McIlroy had been the favourite coming into the week and was two shots clear and in control at the turn in his final round, but then just in front Smith set off on his birdie surge and the pendulum swung definitively his way.
At the age of 28, Smith is the first Australian in almost three decades to win the British Open since Greg Norman claimed his second Claret Jug at Royal St George’s in 1993.
The Brisbane native with the trademark mullet is also the third Australian to win the Open at the home of golf, after Peter Thomson in 1955 and Kel Nagle, who won the Open in 1960.
“To win an Open Championship in itself is going to be a golfer’s highlight but to do it around St Andrews is unbelievable,” he said.
“This place is so cool. I love the golf course and the town.”
Smith’s 20-under-par total of 268 is the lowest winning score in an Open at St Andrews, bettering the performance of Tiger Woods, who won on 19-under in 2000.
In stark contrast to Smith, McIlroy was left to rue a series of missed birdie putts, while Viktor Hovland - who had shared the overnight lead on 16-under - faded badly to shoot a 74.
That left the door open for one of the chasing pack and Smith took full advantage thanks to his incredible performance on the back nine.
As well as the birdies he showed nerves of steel to save par at the 17th, the legendary Road Hole.
Yet he needed his final birdie on 18 as his playing partner Young produced an eagle to finish with a 65 and end on 19-under.
A play-off was avoided and Smith could celebrate his first major after he finished tied third at this year’s Masters, a tournament in which he also came second in 2020.
Before this week his biggest win had come at the Players Championship in March.
McIlroy rues missed putts
If Young, the 25-year-old New Yorker who had been the leader after the first round, can be satisfied with his showing this week, the same ultimately cannot be said for McIlroy.
“Just disappointment I guess. I had a great opportunity today to add to that major tally and I didn’t quite get it done,” McIlroy, who is still stuck on four major titles, told NBC.
“I didn’t feel like I did many things wrong, but the putter went cold on me throughout the round.”
Now 33, few would have thought when he won the 2014 Open at Hoylake and followed it with victory in the PGA Championship a few weeks later that he would then embark on a major drought which will extend into a ninth year.
“I got beaten by the better player this week. To shoot 64 to win an Open Championship at St Andrews is one hell of a showing, so hats off to Cam, he’s had an unbelievable week," McIlroy added.
England’s Tommy Fleetwood finished in a tie for fourth on 14 under par alongside Hovland, who had been hoping to become the first Norwegian winner of a men’s major.
Brian Harman of the United States came tied sixth on 13-under with Dustin Johnson, who was the highest finisher among the 24 players from the breakaway Saudi-backed LIV series in St Andrews this week.
The chief executive of the LIV series is Norman, the 67-year-old who was not invited to St Andrews by organisers the R&A as a result but who will surely be proud of his compatriot’s performance.