LOS ANGELES -- Adversity can take you in different directions. It can break you, or it can make you stronger, more aware.

Juan Rivera, leaning on his experience across six seasons with the Angels, chose to use it as a means of preparation. The approach paid dividends in a dramatic 4-3 Dodgers triumph at the expense of the Cardinals on Saturday night, lifting them into a tie with St. Louis for the second National League Wild Card spot.

Having lost a steady job with the Dodgers when they acquired Shane Victorino and Adrian Gonzalez to play the positions he'd been occupying for much of the season, Rivera quietly went to the batting cage and put in his work. He'd wait for his time, his chance to contribute, and when it came ...

"Be ready," Rivera said. "Just be ready. That's what I keep telling myself. I learned how to do this when I was with the Angels. Playing, not playing. Playing, not playing. I kept taking my swings and stayed as ready as I could be."

In the bottom of the ninth inning at Dodger Stadium, the irrepressible Luis Cruz having kept the Dodgers alive with a two-out, run-scoring double over the head of center fielder John Jay to tie the game, Rivera was summoned by manager Don Mattingly to win it.

And that is what Rivera did, getting just enough of a Jason Motte cut fastball off the end of his bat to slip it off the glove of sprawling second baseman Daniel Descalso.

In came pinch-runner Elian Herrera from second, almost half of the Dodgers team almost beating him to home plate as the throw came too late to the great Yadier Molina.

"It was a good cutter, on the outside corner," Rivera said. "He throws hard. I was looking middle away. I put a good swing on it, but I thought [Descalso] was going to catch it at first. When I saw it hit the ground, I was so excited."

He had a lot of company. A crowd numbering 42,449 -- energized by a magnificent throw by center fielder Matt Kemp erasing Molina at third in the top of the ninth -- stopped chanting "Cruuuuuuz!" long enough to cheer Rivera's game-winner.

Mattingly had Rivera pinch-hitting for catcher A.J. Ellis, who had struck out twice and flied out earlier as southpaw Jaime Garcia was handing the bullpen a 3-2 lead after six innings against Joe Blanton.

The Dodgers were trying to build off the momentum of Friday night's Cruz-controlled victory. But the day had started with the disheartening news that ace Clayton Kershaw would miss his Sunday start and might not pitch again this season with a hip injury that could require surgery.

Allen Craig's two-run blast in the first inning got the Redbirds started, but the Dodgers drew even on Gonzalez's RBI single in the first and Mark Ellis' solo homer in the third.

After World Series star Craig, a local product from Temecula Chaparral High, handed the Cards a lead with a two-out RBI single against Blanton in the sixth, the Dodgers went quietly, in order, in the seventh and eighth.

But Kemp, on another frustrating night offensively with three strikeouts and a groundout, lifted his team and the crowd with his Willie Mays-like throw to nail Molina after his battered body careened off the wall in center.

"I think that pumped us up a little bit," Kemp said.

Andre Ethier got it started with a two-out single to right. Dee Gordon ran for him and stole second -- never easy with Molina's cannon. Cruz, whose clutch heroics have lifted the Dodgers repeatedly, did it again by driving the ball over Jay's head.

Mattingly had Rivera in the on-deck circle, preparing for Motte and his high-90s heat. Rivera had been taking swings in the batting cage behind the dugout every other inning to stay warm.

"I felt the matchup was good for Juan, with his swing," Mattingly said. "I thought A.J. was probably a little tired, and Juan seems to get on a fastball pretty good. Motte is a one-plane guy. It's hard, but it's one level. Juan's an RBI guy, and he's got some experience."

Gonzalez, who'd flied deep to center to open the inning, also liked the matchup with Rivera vs. Motte.

"Juan's got a low-maintenance swing," Gonzalez said. "It's so simple, and he's such a professional hitter. He can play every day or he can play a couple times a week, come off the bench. His swing looks about identical whether he's playing every day or not. I remember when I wasn't playing every day. My swing was a wreck.

"Some people can have that professional, easy swing -- and that's what Juan gave us."

With Rivera in their starting lineup, the Dodgers were 40-31, and they spent a lot of time in first place.

Since Aug. 30, Rivera has had a total of 11 at-bats. The hit was his third. He's not having a season to brag about at 34 -- .242 batting average, .359 slugging, seven homers, 43 RBIs in 298 at-bats -- but the man from Venezuela can hit.

"It's been tough on Juan on a couple of different levels," Mattingly said. "There's the emotional end. You lost a job. Your ego takes a little bit of a hit, from the fact you're not playing every day. To keep working and be ready to go is tough.

"The good thing is he had quite a few at-bats, so coming to a pinch-hitting role, that helps. You don't have to look for your swing."

Rivera's was right there with him on Saturday night, and he produced one of the season's biggest hits for his team.