A five-run comeback in the bottom of the eighth inning gave the Scranton/Wilkes-Barre RailRiders a much-needed 9-8 victory over the Rochester Red Wings in the finale of a six-game series Sunday afternoon at PNC Field in Moosic.

Oswaldo Cabrera and Christian Bethancourt each had three hits and one RBI for the RailRiders (24-13, 61-50), who stopped a four-game losing streak.

They were in jeopardy of dropping their season-high fifth straight game after Rochester scored six runs in the top of the seventh inning to take a 7-3 lead. Trey Lipscomb hit a grand slam, Cayden Wallace had a RBI single and Maxwell Romero Jr. added a RBI double.

Kenedy Corona homered for the RailRiders leading off in the bottom of the seventh, but Seaver King got the run back with a homer leading off the top of the eighth to make it 8-4. It was the 17th home run hit by the Red Wings in the series.

However, the RailRiders responded in the bottom of the eighth.

Marco Luciano drew a leadoff walk, went to second on a single by Cabrera, stole third and scored on a sacrifice fly by Yanquiel Fernandez. Bethancourt singled to send Cabrera to third. Following a pitching change, Duke Ellis, pinch-running for Bethancourt, stole second. A wild pitch allowed Cabrera to score and Ellis to take third. Ernesto Martinez Jr. doubled to right-center field to score Ellis and cut the deficit to 8-7.

With two outs, Anthony Volpe hit a ground ball between third base and shortstop. Third baseman Lipscomb made a diving stop, but his throw to first base skipped past Yohandy Morales for an error that allowed Martinez to score the tying run and Volpe to head to second. Jasson Dominguez then capped the rally with a single to center field to score Volpe and put the RailRiders ahead, 9-8.

Zach Messinger worked a perfect ninth inning to seal the victory and notch his second save. Bradley Hanner (6-2) was the winning pitcher.

Five singles in the bottom of the second inning enabled the RailRiders to jump out to a 2-0 lead. Cabrera, Fernandez and Bethancourt opened the inning with singles, the latter scoring Cabrera. Following a double play, Corona singled to score Fernandez. Volpe also had a hit in the inning.

Leandro Pineda homered off RailRiders starter Brendan Beck with one out in the fifth inning to bring Rochester within 2-1. But in the bottom of the sixth, J.C. Escarra led off with a double and scored on a one-out single by Cabrera to make it 3-1.

Beck allowed one run and four hits in 4.2 innings with three walks and eight strikeouts. In two starts in the series, the Yankees’ No. 19 prospect gave up one run on eight hits in 10.2 innings with four walks and 20 strikeouts.

On Tuesday at 6:45 p.m., the RailRiders head to Allentown to begin a six-game series at Coca-Cola Park against the Lehigh Valley IronPigs.