Homa began the final round in California five strokes behind leader Sam Ryder but produced a remarkable round of 6-under 66.
It gave the 32-year-old American his first victory since becoming a dad. It's also his second win this season having taken down the Fortinet Championship.
He flirted with missing the cut but somehow forced himself into contention, starting two strokes behind Ryder on Saturday.
But Rahm had a day to forget, carding a final round of 2-over par 74.
Rahm made bogey at 1, doubled 5 and, despite putting a stop to the bleeding at 6 with a birdie, he immediately dropped another shot.
As for Ryder, it was a tale of so close but so far. He held a one-stroke lead over Homa for much of the final round.
But disaster struck at 15 when he hit his tee shot into the thick rough, had to chop out and then failed to land his wedge approach on the green.
His golf ball ran through the green, which left him a tricky downhill chip out of the greenside rough. It led to a double bogey and his race was run.
He told the media:
Homa closed the door with birdies at 16 and 18. His wife Lacey was greenside to watch the victory.
Asked how he won, Homa said:
Homa eventually finished two strokes clear of Keegan Bradley. Collin Morikawa, Sahith Theegala, Sungjae Im, Jason Day, Hideki Matsuyama and Tony Finau also finished inside the top 10.
Next page: Jon Rahm past caring about world rankings