New York starter CC Sabathia did not give up a hit until McLouth led off the sixth with a single and the Orioles went on to score three times in that frame to tie it up.
Manny Machado contributed a two-run double in the Baltimore sixth and Adam Jones drove in the tying run with an infield hit.
Sabathia (8-6) was still in the game in the seventh when, with two away, McLouth hit a 1-0 pitch over the wall in right for what turned out to be the game-winning run. The Yankees lost their third in a row despite outhitting the Orioles 11-5.
Rookie Kevin Gausman, recently recalled from Class AAA Norfolk, was credited with the first win of his major league career after working 4 1/3 innings in relief of starter T.J. McFarland.
Gausman (1-3) allowed three hits without a walk and struck out four. Tommy Hunter gave up a hit while pitching the final two innings and collected his second save.
McPhee, Cokas 'working on their marriage' after affair
Attkisson leaves CBS News, reportedly over network's 'liberal bias'