ST. LOUIS — Sometimes baseball defies logic. After starting their road trip with a lopsided series loss to the Pirates, the Cubs played the Cardinals close for three consecutive games.
In the series finale Sunday, they beat the Cardinals 6-5 in 10 innings to take two out of three.
Catcher Willson Contreras delivered the tiebreaking run, leading off the 10th with an RBI single through the right side to drive in Nelson Velazquez, who had started the inning on second.
Before that, the Cubs had battled back from a five-run deficit to tie the score in the fourth.
‘‘I talk a lot about these guys not giving in,’’ manager David Ross said. ‘‘I thought that was a prime example of that. Down that many runs early in the game, last game of a road trip, really good team, off day coming up, and our guys fought really hard. Super-proud of them.’’
Nico Hoerner started the five-run rally in the fourth with a leadoff infield single. Yan Gomes followed with a line-drive single into right field, then Alfonso Rivas beat the shift with a hit through the left side to drive in a run. David Bote then singled up the middle to load the bases.
Christopher Morel struck out to end the streak. But Rafael Ortega and Contreras each followed with two-run hits to tie the score.
The Cardinals finally got out of the inning with a heads-up play by first baseman Paul Goldschmidt. Ian Happ hit a line drive at Goldschmidt, which he dropped. But with the force still in play, he tagged Contreras as he slid back to first, then stepped on the bag for a double play.
Go long
Right-hander Alec Mills ran into trouble his second time through the Cardinals’ batting order. He gave up back-to-back home runs to Brendan Donovan and Goldschmidt to begin the third. Then, with two outs, he threw a sinker middle-in to Juan Yepez, who drove it over the fence.
‘‘The two outings before this, I felt like I was executing OK,’’ Mills said. ‘‘Today was a lot of pitches in the middle [of the strike zone], and big-league hitters did what they were supposed to do with a pitch you miss [over the] middle.’’
Right-hander Matt Swarmer, who originally had been slated to start, replaced Mills with the Cubs trailing 5-0.
Swarmer’s ERA had ballooned from 1.50 to 5.84 in his last three starts, and Ross said he wanted to take a look at him in the bullpen.
Swarmer held the Cardinals hitless through 2⅓ innings.
Heyward out of lineup
Right fielder Jason Heyward has been dealing with a minor knee issue, Ross said. He has been out of the lineup for two games.
‘‘Just trying to give him a day or two,’’ Ross said.
Velazquez and Ortega started in right the last two days.