CHICAGO (AP) — Chicago rookie Kyle Schwarber homered in his second consecutive game to help the Cubs edge San Francisco 5-4 on Thursday, moving half a game ahead of the Giants in the race for the second wild card in the National League.

One team unlikely to require a wild card to make the playoffs is St. Louis, which shut out Cincinnati to move six games clear atop the NL Central standings.

In the American League, Central leader Kansas City lost to a ninth-inning Ian Kinsler homer at Detroit, but nearest divisional rival Minnesota was also beaten, with Toronto completing a four-game sweep of the Twins.

The Cubs, a genuine playoff hope at this stage of a season for the first time in years, won for the seventh time in eight games.

Jorge Soler hit a two-run single in the first inning and Schwarber made it 5-0 with a three-run drive in the second. But instead of an easy win, the Cubs had to hang on.

San Francisco was within a run after six innings, but Chicago's bullpen stood up, with Jason Motte, Pedro Strop and Hector Rondon pitching a scoreless inning each to secure victory.

St. Louis' Michael Wacha gave a tired bullpen a respite by throwing seven innings in the rain to guide the Cardinals to a 3-0 win against Cincinnati.

The Cardinals improved to 30 games over a .500 winning percentage for the first time since the end of the 2013 season. They have the best record in the major leagues at 69-39. They have won 15 of their last 18 series against the Reds, and shut out Cincinnati for 18 innings over the last two games.

Wacha (13-4), who overcame a 68-minute rain delay at the start, allowed only two runners past second base.

Detroit's Ian Kinsler hit a two-run homer in the ninth inning to lift the Tigers past Kansas City 8-6.

Jose Iglesias led off the ninth with a single against Ryan Madson (1-2) before Kinsler hit a fastball into the bullpen beyond left field.

Victor Martinez hit a three-run homer in the third and a two-run shot in the fifth to help the Tigers take a 6-3 lead. Martinez hadn't homered since July 17 and hadn't had a multihomer game in five years.

Toronto's Edwin Encarnacion hit a two-run homer to help the Blue Jays beat struggling Minnesota 9-3.

Encarnacion went 3 for 4 with four RBIs and scored twice for the surging Blue Jays, who won their fifth straight and swept a four-game series from the Twins for the first time.

Toronto starter Mark Buehrle (12-5) allowed three runs in seven innings to win his third consecutive decision. He is 30-19 with a 3.68 ERA in 54 appearances against Minnesota.

The Twins have lost five straight to drop back to an even win-loss record for the first time in three months.

New York's Jacoby Ellsbury hit a tiebreaking homer in the seventh to snap out of a slump and help the Yankees edge Boston 2-1.

C.C. Sabathia pitched six gritty innings after leaving his previous outing with dehydration, leading New York to a series victory over the Red Sox.

Next for the AL East leaders is a key weekend series against Toronto. The division rivals, separated by 4-1/2 games, play the first of 13 remaining games against one another Friday.

Houston's Jed Lowrie hit an RBI double off Edward Mujica with two outs in the 10th inning to lift the Astros over Oakland 5-4.

Washington's Ian Desmond broke out of a prolonged slump with a home run and a double, and Bryce Harper reached base five times to help the Nationals beat Arizona 8-3.

Los Angeles ace Zack Greinke had a rare bad day on the mound but made up for it at the plate, going 3 for 3 with a homer to lead the Dodgers to a 10-8 victory over Philadelphia.

Milwaukee's Khris Davis hit two three-run homers for Milwaukee, powering the Brewers to a 10-1 win against San Diego.

Atlanta's Eury Perez drove in the go-ahead run in the eighth inning and Nick Markakis had three RBIs to help the Braves defeat Miami 9-8.