ST. LOUIS — Brandon Moss decided the best way to work out of his slump was to go to the tape.

A day off spent analyzing video did the trick for the veteran St. Louis infielder.

Moss bounced out of a three-week skid with a tiebreaking home run and Aledmys Diaz connected in his return to the starting lineup, leading the Cardinals to a 4-2 win over the Chicago Cubs on Tuesday night.

St. Louis ensured that the runaway Cubs won’t clinch the NL Central at Busch Stadium. Chicago’s magic number is three, and the series wraps up Wednesday.

The Cardinals remained a half-game behind the New York Mets for the second wild-card spot.

Moss entered the game mired in a 1-for-41 skid. When given Monday off by manager Mike Matheny, Moss chose to pour over video of his better at-bats rather than swing in the batting cages.

“I went in the cage and worked and worked and nothing seemed to come from it,” Moss said. “Yesterday was much more video than anything.

It helped.”

Matheny was glad to see that the day off did the trick.

“He responded well,” Matheny said. “It was a bad rut, but he worked himself through.”

Moss slammed a two-run homer in the sixth off Jason Hammel (14-9).

The Cubs’ Dexter Fowler led off the game with a home run against Jaime Garcia.

Alex Reyes (2-1) won with 4 1/3 innings of scoreless relief. Kevin Siegrist got his second save.

Reyes entered the game with the bases loaded and two out in the second. He immediately fanned Kris Bryant with a 98 mile-per-hour fastball to get out of the jam.

“He came in in a tough spot and saved the day,” Matheny said.

Moss singled in the second and scored on Diaz’s 15th homer of the season. Diaz started for the first time since July 31, when the All-Star shortstop broke his thumb.

Garcia lasted just 1 2/3 innings, the shortest outing in his 146-start career. He gave up two runs and three hits, including Fowler’s seventh leadoff homer of the season.

“I let my team down,” Garcia said. “I’ve been through tough times before. All I can say is I’m going to continue to do what’s in my control to continue to fight.”

Garcia is 0-3 with a 9.94 ERA in his last four home starts.

The Cardinals, who scored all four runs with two outs, are 8-7 against the Cubs, who are 40 games over .500.

St. Louis is 5-2 in Wrigley Field.

Hammel allowed four runs on six hits in 5 2/3 innings. He struck out nine and walked two.

“It seems every time I give up a run, it leaves the yard,” Hammel said. “Pretty frustrating. But, I felt like I pitched pretty well.”

The Cubs have won 33 of 45 games since July 27.

Fowler realizes that nailing down the division crown is just a formality.

“It’s going to happen, it’s a matter of when,” Fowler said. “So we have to keep winning games.”

TRAINER’S ROOM

Cardinals: INF Matt Carpenter was in the starting lineup after leaving Monday’s game with back tightness. … RHP Trevor Rosenthal threw batting practice. He has missed 46 games with shoulder inflammation. … RHP Michael Wacha is expected to be activated off the disabled list tomorrow and could be headed to the bullpen. He has been out since Aug. 9 with shoulder inflammation.

UP NEXT

Cubs LHP Jon Lester (16-4, 2.51) takes on RHP Carlos Martinez (14-7, 3.05) in the final game of the three-game set. Lester has allowed fewer than two runs in each of his last five starts. He is 6-0 with a 1.17 ERA in his previous eight starts. Martinez is 6-3 in 11 day starts this season. He has induced an NL-leading 32 double plays.