The Galaxy (2-6-3, nine points) ended a two-game skid, while the Earthquakes (5-4-3, 18 points) are 0-4-2 in six road matches this season.
San Jose controlled the ball early on and held it through some sustained time in the attacking zone. In the sixth minute, a give-and-go between Paul Marie, Cristian Espinoza and forward Jeremy Ebobisse ended with the latter being denied by Galaxy goalkeeper Jonathan Bond.
A minute later, LA had its first opportunity of the match when Javier "Chicharito" Hernandez's kick from the top left corner of the 6-yard box rolled wide on the far side.
That spurred on the home side, as it picked up the pace and started to control the play.
Hernandez had his third opportunity of the half in the 21st minute, trying to direct a feed from Tyler Boyd that was in the air inside the goal area, but he couldn't make solid contact with it.
Four minutes later, "Chicharito" was at it again from the top of the box, but his shot rolled just wide right.
The Galaxy finally found the back of the net in the 60th minute on a header by Martin Caceres from a corner kick, sending the ball by the outstretched hand of goalkeeper JT Marcinkowski.
San Jose had one of its best chances in the 68th minute when Jamiro Monteiro fired a shot attempt from the top of the goal area, but Bond got a piece of the ball to deflect it away.
Dejan Joveljic made it 2-0 in the first minute of second-half stoppage time when he picked off the ball on the attacking side of midfield before driving to the box and hitting the far side of the net.
Ousseni Bouda cut the Earthquakes' deficit to 2-1 from the goal area in the fourth minute of second-half stoppage time.
The win was just the second of the Galaxy's season as they sit in second-to-last place in the Western Conference. San Jose is in fifth place with 18 points from 12 matches.