Mark Teixeira and Carlos Beltran homered and drove in two runs apiece as the Yankees (48-46) went two games over .500 for the first time since being 4-2 on April 12. New York lost the previous two instances it was one game over .500.
Teixeira went deep on a night when he returned after missing three games with a sore left foot. Beltran hit his 20th home run of the season, the 12th time he has reached that mark in his career.
Those hits came on a night when Pineda (4-9) turned in his most effective outing of the season. He allowed five hits and did not give up a run for the first time since Sept. 19, 2015, against the New York Mets. It was the 11th time in 87 career starts Pineda did not allow a run.
Pineda walked two and struck out eight, marking the eighth time he fanned at least eight hitters. He held the Orioles to one hit in nine at-bats with runners in scoring position and recorded six of his strikeouts in those instances.
Trumbo remained at third when Pineda fanned J.J. Hardy on a check swing with a high fastball and Nolan Reimold with a slider.
Pineda had a 3-0 lead when he exited after 113 pitches, one shy of his season-high.
Dellin Betances, Nick Goody and Chasen Shreve each threw a perfect inning to complete the shutout.
Brett Gardner tripled and scored on Beltran's sacrifice fly in the first.
Teixeira hit his eighth home run with one out in the fourth. He also drew a bases-loaded walk in the sixth.
New York added insurance with a sacrifice fly by Gardner in the seventh and Beltran's drive in the eighth.
The Orioles (53-40) played without Chris Davis and Manny Machado, who sat with stomach viruses. Baltimore, which has scored twice in 27 innings in New York, was blanked for the first time since May 17 and the fifth instance overall this year.
Yovani Gallardo (3-2) allowed four runs and five hits in seven innings.
NOTES: Baltimore 1B Chris Davis (stomach virus) took batting practice and ground balls but missed his third straight game. The same stomach virus also impacted Orioles 3B Manny Machado, who missed his fifth game of the season. "It's a pretty good virus that's hitting some of our guys and it's knocking them out," said bench coach John Russell, who filled in for manager Buck Showalter (stomach virus). ... New York 3B Chase Headley did not start due to personal reasons. He had been in the original lineup before a revision was announced about two hours before first pitch. ... RHP Darren O'Day (strained right hamstring) will pitch the first inning for Double-A Bowie on Friday. He could be activated Sunday or Monday.