CHICAGO (AP) — Wade Miley was terrific, and Kyle Farmer made a pair of clutch plays. Jonathan India and Nick Castellanos had a couple of big swings.

They all stepped up on a night when Cincinnati desperately needed a win.

Miley pitched seven effective innings, Castellanos homered and the Reds cooled off the Chicago Cubs with a 4-3 victory Tuesday.

Cincinnati had dropped seven of nine to lose ground in the NL playoff race. It began the day one game back of San Diego for the second wild card.

“We needed that as a squad,” Miley said. “We've been scuffling a little bit of late.”

The Reds bounced back behind Miley (12-5), who was coming off one of his worst performances during an impressive season. The veteran left-hander allowed one run and five hits, struck out eight and walked none.

Miley, tagged for five runs and 12 hits over four innings during a 5-4 loss to the Cardinals last week, improved to 6-1 with a 2.67 ERA in his last 11 starts.

“He did what he's done all year,” manager David Bell said.

Willson Contreras, Rafael Ortega and Ian Happ homered for Chicago, which had won a season-high seven straight. Happ, who finished with three hits, is batting .367 (33 for 90) in his last 24 games.

“We were right there until the end,” said bench coach Andy Green, who is running the Cubs while manager David Ross is away from the team following a positive COVID-19 test.

The Reds were clinging to a 2-1 lead before they pushed across two runs in the eighth. India, who homered in the first, doubled and scored on Mike Moustakas' two-out single off Manuel Rodríguez. Farmer tacked on another RBI single.

Ortega and Happ connected in the bottom half against Michael Lorenzen, but Mychal Givens worked the ninth for his sixth save.

Right before Happ's 20th homer, Farmer robbed Frank Schwindel of a hit when the shortstop ran back into short center field for a terrific catch.

“That was unbelievable,” India said.

It reminded Farmer of a tragic moment from his college career at the University of Georgia, when outfielders Johnathan Taylor and Zach Cone collided while chasing a line drive against Florida State in 2011.

The 31-year-old Farmer said Taylor has been paralyzed from the neck down since the play.

“I grew up playing with J.T. and Zach since we were like 10, so I know them really well,” Farmer said. “So that play right there means a lot to make. I kind of overcame a big step mentally there. It was difficult physically and mentally.”

India drove Adrian Sampson's third pitch into the bleachers in center for his fifth leadoff homer and No. 19 overall in his first big league season. After Tyler Naquin bounced to third, Castellanos connected for his 27th homer.

India's homer traveled an estimated 422 feet, and Castellanos' drive went even further at 446 feet — landing on a green roof in center. But then Sampson (0-2) settled down nicely, allowing six hits over a season-high five innings in his second start of the year.

“They just jumped on some pitches early, but I thought I limited the damage after that,” Sampson said.

The Cubs got one back on Contreras' 18th homer, a two-out drive to left-center in the third. They almost got the tying run in the sixth, but the Reds caught a break.

With two out and Happ on first, Patrick Wisdom's drive to left-center got lost in the ivy for a ground-rule double. That meant Happ had to go back to third, and Matt Duffy tapped back to Miley for the final out of the inning.

TRAINER'S ROOM

Reds: OF Jesse Winker (intercostal strain) had to slow down for a day or two after he felt “a little something,” according to Bell. But the All-Star slugger could appear in some minor league games within the week. “It's the last step, really. It's just being able to swing, take full swings,” Bell said. “That's a big step with that injury.”

Cubs: RF Jason Heyward was scratched due to right hamstring cramping. Wisdom moved from left field to right with Heyward out, and Alfonso Rivas entered the lineup in left. ... OF Michael Hermosillo is dealing with some left forearm soreness. He entered as a pinch-runner in the ninth. ... Green said INF Nico Hoerner (right oblique strain) is doing well after working out Monday. “He's still got a few more hurdles to clear before I think the medical staff feels good about him being out in a competitive setting again,” Green said.

UP NEXT

Right-handers Vladimir Gutierrez (9-6, 4.17 ERA) and Alec Mills (6-6, 4.25) pitch Wednesday in the series finale. Gutierrez has dropped his last two starts for Cincinnati, allowing eight earned runs in 6 1/3 innings. Mills is 2-2 with a 3.66 ERA over his last six outings for Chicago.

___

Jay Cohen can be reached at https://twitter.com/jcohenap

___

More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP_Sports