CARSON -- The most prolific goal-scoring team in Major League Soccer had a terrible attack Sunday night in the first leg of the Western Conference semifinals at the Home Depot Center.

Then strapping defender Victor Bernardez let one fly on a free kick with seconds left to give the Earthquakes a stirring 1-0 victory over rival Los Angeles in front of a sellout crowd of 27,000.

The 6-foot-2 Honduran international stunned the Galaxy with another late goal to put San Jose a step closer to reaching the conference finals after more than 90 minutes of taut action that seemed headed for a scoreless draw.

Bernardez spent the game trying to fend off Los Angeles' galaxy of stars, including Ireland's Robbie Keane. But when it was his time to strike, the center back had one thought:

"I wanted to score, my ambition is to always to score a goal," Bernardez said in Spanish.

The 31-yard strike left MLS's reigning champions dazed. But the Galaxy should be used to it by now.

On May 23 in Carson, Alan Gordon headed home a 94th-minute winner for a 3-2 victory. In all, the Quakes had rallied three times against Los Angeles this year, winning twice and tying last month at Buck Shaw.

Now the teams play Wednesday night in Santa Clara, where the series will be determined on total goals in both games.

The Quakes (19-6-9 in regular season) have not lost at Buck Shaw in 18 matches dating to last season. They need just a tie to advance against Seattle or Real Salt Lake next week.

The Earthquakes don't plan to back off, the players promised.

"It would be really foolish for us to count them out at any point," said Alan Gordon, who played in the second half despite nursing an ankle sprain. "We've got to stay sharp and stay ready to fight."

It could not have worked out much better for MLS's top-scoring team with 72 goals in the regular season.

But it sure didn't seem like it would end with a San Jose victory. Keeping Los Angeles (16-12-6) out of the net took a collective effort.

"We talked about tightening up things defensively," Quakes center back Jason Hernandez said.

The Earthquakes also got lucky. Keane, who had 16 goals in the regular season, was a handful all night. He hit the crossbar with a dangerous 26-yard strike in the 86th minute that might have turned the game in the Galaxy's favor.

But second-half substitute Simon Dawkins gave San Jose one last try in extra time when getting fouled near the penalty area. Los Angeles coach Bruce Arena took exception to the call.

"No foul, if that's a foul in this game, then there is 100 fouls," he said.

Bernardez likes to take shots from distance. He struck a low-lying ball that got past the wall and squirted underneath L.A. goalkeeper Josh Saunders as the Galaxy looked dazed.

"You know he's going to hit it with pace, he hits the ball very well," Saunders said. "It took a weird spin, kind of got caught under me, and it was behind me before I knew it."

It was the Quakes' 10th stoppage-time goal this year and sixth game-winner.

Bernardez's goal adds to the memorable playoff matches between the California rivals. The 2003 series was one of MLS's best in history, when San Jose rallied from a two-goal deficit in the first game to advance to the conference finals.

Two years later, the Quakes won the Supporters' Shield as regular-season champions only to get bounced by Los Angeles in the first-round of the playoffs.

Despite numerous injuries, the Galaxy had lost only one game in its previous 10, including a knock-out playoff game against the Vancouver Whitecaps on Thursday. Los Angeles had won five consecutive playoff games until Sunday.

Earthquakes coach Frank Yallop had no illusions about what to expect Wednesday.

"We are ready for another difficult game," he said.

Contact Elliott Almond at 408-920-5865. Follow him on Twitter at twitter.com/elliottalmond.