Two innings after the Cardinals lost their lead when a ball skipped between his legs, catcher Yadier Molina threaded a hit through two Cubs to get it back and rescue his teammates from a wasted weekend in Wrigleyville.

Down to his final strike and the Cardinals’ final out in the ninth inning, Molina poked a ground ball up the middle and past a diving Starlin Castro to drive home two and avoid a sweep by the host Cubs. Molina’s two-run single off Cubs closer Hector Rondon erased earlier mishaps and delivered a 5-4 victory late Sunday night at Wrigley Field.

The four Cardinals ahead of Molina put the rally in motion with the parade of at-bats that have been absent so far this year. Randal Grichuk’s walk and Mark Ellis’ single got the key runners on base, and Matt Carpenter’s two-out walk loaded the bases and left Rondon nowhere to go with Molina. Even Peter Bourjos’ nine-pitch strikeout tenderized the closer minutes before the winner.

“We haven’t hit the way we want to,” Molina said. “They did a great job getting on base for me to give me that opportunity. We took some good at-bats that last inning. I feel we’re going to come through. We’ve got a good offense. We do. I trust my teammates.”

The Cardinals surged early to a 3-0 lead only to see the Cubs pick away at it with runs that should have been avoided. Opposing pitcher Jason Hammel’s first hit of the season drove in two runs off Lance Lynn, and the tying run came home on a wild pitch that sneaked through Molina’s butterfly-like save, one he’s made countless times. Molina afterward described how it’s the kind of pitch he blocks “99 times out of 100.” Manager Mike Matheny said that Molina does a good job drawing a curtain between defense and offense, but teammates knew Molina craved a crack at undoing the damage of Carlos Martinez’s wild pitch.

Rookie Grichuk sparked the ninth when he drew a won from Rondon. Ellis followed with a single, his third hit of the game. Bourjos, a late-game defensive sub, saw nine pitches and fouled off five before striking out. A day earlier, Carpenter said lengthy at-bats — he mentioned eight-pitch ordeals — can often yield success for the next batter. He didn’t know the numbers, just the anecdotes, such as his walk immediately after Bourjos’ at-bat.

With the bases loaded, Molina fouled off three consecutive fastballs from Rondon. He didn’t bite on a breaking ball in the dirt. The Cubs had him shaded over to pull to the left side of the infield, and Molina steered a base hit up the middle.