NEW YORK (AP) Brian McCann hit a tying, three-run homer off Sam Dyson, Didi Gregorius capped a six-run ninth inning with his two-run shot and the New York Yankees woke up late to beat the Texas Rangers 9-7 Wednesday night.

Down 7-2 and in danger of falling 10 games behind AL East-leading Baltimore, the Yankees began their comeback when McCann homered off Cesar Ramos in the eighth.

Rob Refsnyder singled off Matt Bush leading off the ninth, Jacoby Ellsbury singled and Dyson (1-2) relieved.

More from FoxSports

Brett Gardner singled and Refsnyder came home when center fielder Ian Desmond bobbled the ball for an error. After Alex Rodriguez lined out, McCann homered into the right-field bleachers, Starlin Castro walked and Gregorius lined the ball into the right-field seats for his first career game-ending homer.

Luis Cessa (1-0) allowed one run in three innings for his first big league win.