San Jose were almost level immediately but Carlo Cudicini made a good stop to deny Salinas as his low effort seem destined for the bottom corner before the keeper got a hand on it to turn it past the post.
Robbie Rogers somehow missed an open goal for the Galaxy to deny themselves a two-goal cushion, while at the other end Cudicini made a great double save to prevent Marvin Chavez from getting his side level.
The Galaxy did double their lead when Hector Jimenez slotted the ball into an empty net after collecting Keane's pass across the face of goal at the back post.
However, San Jose hit back straight away through Gordon as he headed home Salinas's pinpoint cross into the net at the near post.
The Earthquakes were the dealt a blow as they were reduced to 10 men when Victor Bernandez was shown a second yellow card for a late challenge on Donovan.
This didn't stop San Jose, though, as they kept pressing for an equaliser and got their goal in the 92nd minute when Adam Jahn's headed effort was spilled by Cudicini and Salinas was there to tap in the rebound.
The Earthquakes secured an incredible victory when Sam Cronin lifted a lovely cross to the back post where Gordon was there to powerful head the ball into the net and send the Stanford Stadium into raptures.