BALTIMORE (AP) Jonathan Lucroy hit his first homer with Texas, Ian Desmond drove in two runs and the Rangers beat Wade Miley and the Baltimore Orioles 5-3 Thursday night to avoid a three-game sweep.

Texas received contributions from all three players it acquired before Monday's non-waiver trade deadline. Lucroy homered in the second inning, Carlos Beltran singled in a run in the fifth and Jeremy Jeffress pitched a scoreless seventh.

Shin-Soo Choo came off the disabled list to get two hits and scored a run for the Rangers, who took back from Baltimore the distinction of owning the best record in the AL.

More from FoxSports

Texas won the season series 4-3 and would have home-field advantage in the postseason if the teams finish with the same regular-season record and meet in the playoffs.

Mark Trumbo hit his major-league leading 31st homer for the Orioles, who fell to 39-17 at home. Pedro Alvarez and Hyun-Soo Kim also hit solo shots.

Miley (7-9) gave up four runs and eight hits in five innings in his debut with the Orioles. The left-hander was traded by Seattle on Sunday.

Miley took a line drive off his ankle for the final out in the fifth. He appeared to be OK, but manager Buck Showalter went to bullpen in the sixth.

A.J. Griffin (5-1) allowed three homers in 5 1/3 innings but won a second straight start following a six-game run without a victory. Sam Dyson, the fifth Texas pitcher, worked a perfect ninth for his 23rd save.

After Lucroy put the Rangers up 1-0, Desmond added a run-scoring groundout in the second.

Texas made it 4-0 in the fifth on RBI singles by Desmond and Beltran. Desmond's single bounced past first baseman Chris Davis, who was screened by Choo advancing to second, and Beltran's pop bounced off the glove of second baseman Jonathan Schoop in right field.

Trumbo and Alvarez homered in succession in the bottom half, and Kim led off the sixth with his fourth homer of the season - his first at Camden Yards.

Back-to-back doubles by Adrian Beltre and Roughned Odor off Logan Ondrusek made it 5-3 in the eighth.

TRAINER'S ROOM

Rangers: Choo spent the minimum 15 days on the disabled list with lower back inflammation. It was his third stint on the DL this season.

UP NEXT

Rangers: Martin Perez (7-7, 4.22 ERA) starts for Texas on Friday night in the opener of a three-game series in Houston. The Rangers are 9-1 against the Astros this season.

Orioles: Baltimore starts a 10-game trip Friday night by facing former teammate Miguel Gonzalez (2-5, 4.06) and the Chicago White Sox.