NEW YORK (AP) Starling Castro hit a two-run homer and drove in four runs, Nathan Eovaldi won for the first time since May and the New York Yankees beat the Baltimore Orioles 7-1 Tuesday night to move back above .500.

Castro homered in the second off Vance Worley (2-1) and hit a two-run double in the sixth against Odrisamer Despaigne. Chase Headley added a two-run homer off Mychal Givens in the eighth.

Trying to keep management from jettisoning veterans for prospects before the Aug. 1 trade deadline, the Yankees won their third straight and ensured they would be no more than five games back for the second AL wild card. At 47-46, New York is above .500 for just the third time since mid-April.

More from FoxSports

New York was 4-2 before dropping to 9-17 and later got above .500 at 31-30 and 37-36 only to regress.

Making his first start since July 1 following three relief outings caused by a six-start winless streak, Eovaldi (8-6) won for the first time since May 29. He allowed one run and four hits in 5 1/3 innings, needing 18 pitches to get through the first but 37 for the next four.

Eovaldi retired 11 straight batters before walking Ryan Flaherty in the sixth with a 3-1 lead. He gave up Joey Rickard's RBI double and loaded the bases with a walk to Manny Machado.

Anthony Swarzak got major league home run leader Mark Trumbo to foul out to Rob Refsnyder down the right-field line, and the rookie first baseman made a two-hop throw home that held Adam Jones at third. Jonathan Schoop then fouled out to shortstop Didi Gregorius. Swarzak retired eighth straight batters, and Nick Goody struck out the side in a perfect ninth, giving the Yankees' No Runs DMC trio a rest.

Worley (2-1), wearing glasses with bright orange frames, made his first start since April 15 following 18 consecutive relief appearances. He allowed three runs, three hits and four walks in 4 1/3 innings, lasting 88 pitches.

Baltimore has lost three straight, and its AL East lead over second-place Boston was cut to one-half game. First baseman Chris Davis (stomach virus) missed his second straight game and catcher Matt Wieters (sore right foot) also was out.

New York's Jacoby Ellsbury grounded to shortstop in the first but his swing knocked off the glove of Caleb Joseph, who was charged with catcher's interference. Ellsbury has reached on catcher's interference nine times, the most in a season since Roberto Kelly's eight, also for the Yankees, in 1992. Ellsbury has done it 23 times in his career, the most among major leaguers since Pete Rose's 29, according to the Elias Sports Bureau.

After New York failed to score in the first inning for the 23rd consecutive game, Castro followed Gregorius' 10-pitch, second-inning walk with a drive into the left-field second deck. His 11th home run matched his total last year with the Chicago Cubs and is three shy of his career high.

Refsnyder, the No. 9 hitter, walked in the fifth, stole second and scored on Ellsbury's single just under the glove of Schoop at second.

LOOKING AHEAD

The Yankees open the 2017 season at Tampa Bay on April 3, according to the team's draft preliminary schedule, then go to Baltimore before their home opener, slated to be against the Rays on April 10. Some openers likely will be moved to April 2 for ESPN telecasts.

TRAINER'S ROOM

Orioles: OF Hyun Soo Kim (strained right hamstring) was put on the 15-day DL retroactive to July 11 and Baltimore selected the contract of OF Julio Borbon from Double-A Bowie. OF Henry Urrutia was designated for assignment. ... RHP Darren O'Day (strained right hamstring) threw a 35-pitch simulated game. He could make a minor league appearance Friday for Bowie and be activated Sunday or Monday.

Yankees: 1B Mark Teixeira was out of the starting lineup for the third straight game because of a sore left foot.

UP NEXT

RHP Michael Pineda (3-9) is to start for the Yankees on Wednesday and RHP Yovani Gallardo (3-1) for the Orioles. Pineda is 0-3 with a 4.46 ERA in six starts since beating the Los Angeles Angels on June 7. Gallardo hasn't gotten a decision in his last three outings; he is 2-0 with a 5.04 ERA in six starts since he was activated June 18 following a stint on the DL caused by right biceps tendinitis.