CLEVELAND — Rookie right-hander Shane Bieber pitched into the eighth inning and Cleveland’s shaky bullpen narrowly closed things out, lifting the Indians over the New York Yankees 6-5 on Friday night.

Bieber (5-1) was removed after Tyler Wade’s leadoff double in the eighth with Cleveland leading 6-3. Brett Gardner’s RBI groundout cut the lead to two and set up a tense ninth inning.

Closer Cody Allen, who allowed a career-high six runs in the ninth inning against Cincinnati on Tuesday, gave up Giancarlo Stanton’s leadoff homer. Greg Bird followed with a single, but Allen got Miguel Andujar to bounce into a double play.

Allen walked Neil Walker, but pinch-hitter Didi Gregorius popped up to shortstop Francisco Lindor in shallow left field as Allen recorded his 19th save in 20 chances.

Jose Ramirez, the starting third baseman for the AL in the All-Star Game, drove in two runs with a groundout in the first and a triple in the fifth. Michael Brantley, also an All-Star, hit a two-run double in the second.

The Indians broke a seven-game losing streak against the Yankees dating to last season’s AL Division Series, when New York came back from a 2-0 deficit. The Yankees won the first four games between the teams this season.

Bieber allowed four runs – three earned – in seven-plus innings. The right-hander was making his seventh major league start.

Yankees rookie Domingo German (2-5) allowed six runs – matching a season high – in four-plus innings.

RANGERS 5, ORIOLES 4: Ryan Rua had a tie-breaking, pinch-hit three-run homer in the seventh inning and Texas held on for a win at Baltimore.

Cole Hamels (5-8) won for the first time in almost a month, allowing four runs and five hits with three strikeouts and one walk over 6 1/3 innings in a matchup of last-place teams.

Rua broke a 1-1 deadlock with the first pinch hit of his career, off rookie Tanner Scott. Nomar Mazara added an RBI double later that inning.

The Orioles have lost 17 of 20 and fell to 14-33 at Camden Yards, the second-worst home mark in the majors behind Kansas City.

NATIONAL LEAGUE

PHILLIES 2, MARLINS 0: Aaron Altherr drove in his first run of July and started a sensational relay that nailed Cameron Maybin at the plate, helping Jake Arrieta and NL East-leading Philadelphia Phillies win at Miami.

Arrieta (7-6) pitched seven innings of three-hit ball. Victor Arano got three outs and Pat Neshek finished for his first save.

Maikel Franco hit his 13th homer of the season in the ninth for the Phillies, who have won 10 of their last 13.

Altherr, who came in hitting only .169, doubled home Scott Kingery in the second inning.

METS 4, NATIONALS 2: Noah Syndergaard pitched out of trouble in a rusty return from the disabled list and helped himself with an RBI single as New York beat visiting Washington.

Amed Rosario tripled and doubled, both times over Bryce Harper’s head in center field, and the Mets won for only the sixth time in their last 26 home games. Brandon Nimmo had three hits for New York, which built a three-run cushion in the first inning against struggling starter Tanner Roark.

After missing seven weeks because of a strained ligament in his right index finger, Syndergaard (5-1) gave up seven hits in five innings.

PIRATES 7, BREWERS 3: Josh Bell tied a career with four hits, Gregory Polanco homered and both drove in two runs to lead Pittsburgh to a win at home.

Nick Kingham (4-4) tied a career high with nine strikeouts and allowed three runs over 61/3 innings. Kyle Crick got four outs for his second save of the season.