The 35-year-old, who won the Honda Classic last week, began three shots adrift of McIlroy but closed with a three-under 69 to win on 12 under.
He holed a six-foot putt on the last to beat Bubba Watson (68) by one shot.
Northern Ireland's McIlroy had a two-over 74 to join England's Danny Willett (69) in a tie for third on 10 under.
Scott began his round with a birdie, but double bogeys on the third and fifth looked to have derailed his challenge as he fell six shots adrift of McIlroy, who opened with six pars.
However, six birdies in his next nine holes, as McIlroy dropped three shots, gave Scott a lead he did not relinquish.
"You have to push yourself so hard to beat the class of players that is out here right now," said Scott.
"So I can't believe I won back-to-back weeks. To win a world championship event is huge. I'm going to push hard the next few weeks."
McIlroy, who also missed out on victory at the Northern Trust Open last month after a poor final round, said: "I didn't make enough birdies. I felt like my game was OK for the most part, but I didn't take advantage of the holes I should have. I couldn't birdie any of the par fives and that's really what killed me today.
"It's frustrating because it's two out of the last three weeks. I was leading the golf tournament with 16 holes to play in Riviera, I was leading the golf tournament here going into the back nine, and to not get the job done in either two of those instances is very frustrating.
"I've got two events left to try to get that win before going to Augusta [for the Masters, 7-10 April] and I'm hopefully going to get it."
Australia's Steven Bowditch, 32, recorded the worst ever score in a WGC event after a 12-over-par final round left him 37 over for the tournament.
Australia's Adam Scott recorded back-to-back victories on the PGA Tour as Rory McIlroy's challenge unravelled at the World Golf Championship at Doral.