LOS ANGELES — The Los Angeles Dodgers found themselves with their backs against the wall because they had somehow squandered two of the surest things in baseball.

Though they had received gems from their aces Zack Greinke and Clayton Kershaw, it was the Cardinals who led two-games-to-none in the National League Championship Series.

But in Game 3, the Dodgers finally reaped the rewards of their outstanding starting pitching, beating the Cardinals 3-0 last night behind the strength of seven shutout innings by lefthander Hyun-Jin Ryu.

The Dodgers pulled out all the stops to get back into this series. Shortstop Hanley Ramirez played through a cracked rib and finished with two bloop hits, including an RBI single in the eighth to give the Dodgers an insurance run.

“I couldn’t be better,” Ramirez said on the field after the game, much to the delight of a crowd that roared every time he came to the plate.’

Centerfielder Andrew Ethier also returned to the lineup, playing through a troublesome ankle injury.

And for the first time in the NLCS, the Dodgers looked like themselves.

The Dodgers snapped a scoreless streak that had reached 22 innings, tagging Cardinals ace Adam Wainwright for a pair of runs in the fourth inning. It was enough for the Dodgers to send Wainwright to his first career postseason loss.

A year ago, Cardinals let the pennant slip through their fingers, falling in the NLCS despite holding a 3-1 series lead against the Giants. The Cardinals found themselves in a similar position, up 2-0 against the Dodgers.

Only two teams in history — the 1985 Dodgers and the 1984 Cubs — have gone on to lose the NLCS after blowing a two-games-to-none advantage.

“Right now, it’s just play the game, keep going, keep your head down,” Cardinals manager Mike Matheny said. “But what we learned last year is just how fragile this is and how quickly it can get away from you.”

Yet, in Game 3, it was the Cardinals who made uncharacteristic mistakes that ultimately swayed the outcome. The worst blunder came in the pivotal fourth, when centerfielder Jon Jay and rightfielder Carlos Beltran slowed up on Mark Ellis’ fly ball to right center.

The ball fell between them, Ellis pulled into second base, and the Dodgers were in position to rally.

Adrian Gonzalez lined a double to rightfield, allowing Ellis to score. And two batters later, Yasiel Puig tripled home Gonzalez, snapping what had been an 0-for-11 skid in the NLCS.

Wainwright limited the Dodgers to just two runs but it wasn’t enough against Ryu, who did not allow a hit until David Freese’s single to lead off the fifth.

The rookie lefthander had been battered in his lone NLDS start against the Braves, during which he admitted to battling a case of nerves.

“I was a bit nervous,” Ryu said through a translator on Sunday. “Although, I believe being completely nerve-free is also a bad thing as a competitor.”

Ryu talked about the importance of “finding a good balance,” which he seemed to strike against the Cardinals. With his team in desperate need of a win, Ryu bounced back allow just three hits with four strikeouts over his seven innings.

For the first time in the NLCS, both teams have gone homerless in the first three games. Meanwhile, the Cardinals have been held to just a .134 average in the first three games.