The Holywood man overcame a poor front nine which saw him surrender his one-shot overnight lead before charging home on the back nine for a three-under 68, to win by one from American Phil Mickelson, who shot a closing 66.
Afterwards, the 25-year-old said: “These past few months have been beyond my wildest dreams.”
Following his victory in the Open at Royal Liverpool last month, McIlroy became the first player since Padraig Harrington in 2008 to win back-to-back majors.
Lifting the Wanamaker Trophy for the second time also saw the Northern Irishman become the third youngest player after Tiger Woods and Jack Nicklaus to win four majors, just one less than the total won by the late Seve Ballesteros and two behind Nick Faldo.
It was the fourth time McIlroy had held the 54-hole lead in a major, the first leading to heartache in the 2011 Masters when he was four ahead entering the final round at Augusta only to collapse to a closing 80.
Two months later he bounced back in spectacular style to win the US Open by eight shots at Congressional before winning the 2012 US PGA by the same margin at Kiawah Island.
Last month he led from start to finish at Royal Liverpool, taking a six-shot lead into the final round before going on to win by two from Sergio Garcia and Rickie Fowler.
This was far more dramatic – a remarkable rain-affected final day which finished in near-darkness, with the lights blazing from the clubhouse behind the 18th green.
Fowler and Henrik Stenson had been part of a three-way tie for the lead with Mickelson on the back nine but dropped shots on the closing stretch to finish two behind McIlroy on 14 under.
A torrential downpour which flooded the course and caused a delay of almost two hours meant it was a race against time to get play finished, so much so that Mickelson and Fowler stood aside on the 18th to allow the final group to tee off.
McIlroy’s drive finished dangerously close to the water to the right of the fairway, but a closing par five from a greenside bunker was enough for the 25-year-old to win his second US PGA title.
Earlier, McIlroy had dropped two shots in his first six holes and trailed Fowler by three as he reached the turn, Fowler having recovered from a bogey on the second with four birdies in his next five holes.
The par-five 10th had cost McIlroy a double-bogey seven on Thursday but three days later he hit a fairway wood to seven feet and holed the eagle putt to get back into contention in stunning fashion.
Mickelson then birdied the 11th to join his playing partner Fowler in the lead, the pair exchanging fist-bumps as they walked to the 12th tee, and Stenson made it a three-way tie with a birdie on the 13th.
Stenson had offered a prayer of thanks to the golfing Gods when his approach had just carried the water, only to three-putt the next to drop out of the lead and effectively end his chances of a first major title.
McIlroy missed good birdie chances on the 11th and 12th, the latter after seeing Mickelson in the group ahead hole from 30 feet across the green for an unlikely par.
But the world No 1 made no mistake from eight feet on the 13th to get back into a share of the lead with five holes remaining.
Fowler was the first to crack under the pressure after a wayward tee shot led to a bogey on the 14th, and when Mickelson bogeyed the 16th, McIlroy was back in the outright lead for the first time since the third hole.
As the light quickly faded, McIlroy delivered the killer blow with a birdie from nine feet on the 17th to enjoy a two-shot lead playing the last.
Mickelson did not seem happy with being asked to make way for McIlroy on the 18th but almost holed his pitch shot for an eagle, the birdie forcing McIlroy to make par for the win.