Baltimore got solo home runs from Manny Machado, Chris Davis and Nate McLouth while Robinson Cano hit one for the Yankees.
Orioles' starter Chris Tillman (3.68 ERA) improved to 10-2 on the season while Yankees' pitcher Hiroki Kuroda (2.95 ERA) fell to 7-6.
The Yankees have lost five straight games and struggled at the plate throughout June. New York's .225 team batting average in June was second-worst in MLB.
The O's have won four straight to move to just 2.5 games back of the AL East-leading Boston Red Sox.
Final: Orioles 4, Yankees 2