The Earthquakes appeared to have a 1-0 win wrapped up in the 92nd minute, but Seattle's Fredy Montero stunned them with an equalizer when he headed a loose ball past San Jose goalkeeper Jon Busch from close range.
Not be outdone, however, the Quakes answered seconds later.
On the last play of the game, Lenhart headed in a corner kick delivery from Shea Salinas, and San Jose (14-5-5) pulled out a victory to extend its lead in the Western Conference.
Simon Dawkins also tallied for San Jose.
The Sounders (10-6-7), meanwhile, saw their six-game MLS unbeaten streak snapped.