Mahan, who won the Match Play Championship in February, is the first two-time champion on the PGA Tour this year. The victory moved Mahan up to No. 4 in the world rankings, the first time he's ever been the highest-ranked American.
Pettersson (71) finished with eight pars for his second runner-up finish this year. Third-round leader Louis Oosthuizen (75) was another shot back at 14 under.
Mahan began the day two shots behind Oosthuizen, who lost the lead with two double bogeys on his front nine.
The 29-year-old Mahan earned his fifth career victory. He has six top-25 finishes in seven starts this year.
Standing on the 18th tee with a one-stroke lead, Mahan confidently hit his tee shot down the middle of the fairway, then knocked his 203-yard approach to 21 feet. He gave caddie John Wood a high-five when the ball landed safely on the green.
"Absolutely awesome," Wood said.
Defending champion Phil Mickelson (71), Keegan Bradley (71), Brian Davis (74) and Jeff Overton (68) all finished 12 under.
The tournament became the run-up event to the Masters in 2007, and Mahan will play at Augusta for the fifth straight year.
Three-time major champion Ernie Els finished 10 under and fell short in his bid to earn an automatic invitation to this week's Masters. Els needed a victory to avoid missing Augusta for the first time since 1993.
"It's not going to change my life, either way," Els said. "I've played many out there. It's one of those things."
The Masters could still offer a special invitation to Els, like tournament officials did for Greg Norman in 2002.
Els has played well this year, earning top-five finishes at the Transitions and Bay Hill. But he said Sunday he would decline an invitation if he received one at the last minute.
"To go through all of this, and then get an invite, I wouldn't take it," he said. "They can keep it."
The problems for Oosthuizen began with a three-putt on No. 2. He holed a downhill 45-footer for a birdie on No. 3, but hit his tee shot on No. 5 into a divot and missed the green with his approach. He botched a chip and two-putted from 20 feet.
Oosthuizen pulled his approach to the par-5 8th into the native area, leading to his second double bogey.
Mahan parred the first eight holes, then finally took advantage of Oosthuizen's collapse with a 5-foot birdie putt on No. 9. Pettersson missed a 19-foot par putt on No. 10, leaving Mahan in the lead by himself at 16 under.
Mahan found a greenside bunker on No. 14 and bogeyed, then hooked his tee shot to the 204-yard, par-3 16th. He pitched onto the green, and the ball rolled down a slope to within 16 inches for an easy tap-in par.
Pettersson left an 18-foot birdie putt short on the 488-yard 18th, the hardest hole on the course, with a pond running down the length of the fairway on the left. Like Els, Pettersson needed a win to earn a trip to Augusta.