"This is huge ... one of the coolest wins of my life," said Edwards, who had not won a Sprint Cup Series race since he took first in Las Vegas on March 6, 2011.
Edwards, who drives the No. 99 Ford for Roush Fenway Racing, appeared to have the Subway Fresh Fit 500 in hand if he hadn't run out of fuel on the one-mile Phoenix track.
But with only three laps left in the race, Ken Schrader's spin brought out a caution period, setting up a two-lap "green-white-checker" shootout.
Restarting on the inside lane, Edwards got a big push from Brad Keselowski, jumped to the lead and held on for the win.
Keselowski finished fourth, Dale Earnhardt was fifth and Clint Bowyer took sixth.