Los Angeles: David Beckham’s Los Angeles Galaxy suffered a shock 1-0 home defeat by the San Jose Earthquakes in the first leg of Major League Soccer’s Western Conference play-off on Sunday.

Victor Bernardez blasted in a free-kick in stoppage-time, stunning the LA crowd after the match looked to be heading for a stalemate between the top-scoring teams in MLS. The defending champions Galaxy will have it all to do in the second leg at San Jose on Wednesday.

Bernardez rifled a bullet shot through the wall of Galaxy defenders, which flew under the outstretched arms of goalkeeper Josh Saunders.

Former England captain Beckham, reported to be leaving LA after his contract expires at the end of December, was replaced by Edson Buddle with 10 minutes left in the game.

LA escaped a potential season-ending playoff defeat by Vancouver last Thursday with a 2-1 comeback 2-1, but paid for not taking their chances against the Earthquake.

Substitute Buddle squandered the home team’s best opportunity in the 87th minute with a weak shot with Robbie Keane wide open.

The Earthquakes, owners of the season’s best record and boasting the league’s top scorer in Chris Wondolowski, came into the match after eight days off.

Wondolowski, who tied an MLS single-season record with 27 goals, failed to get on the scoresheet but Bernardez’s stunning strike proved enough for San Jose.