New York has dropped seven of 10 and fell 6½ games behind AL-East leading Tampa Bay.
Texas took an 8-2 lead into the eighth, but Richie Sexson's grand-slam off C.J. Wilson made it a two-run game.
Wilson, the Rangers' closer, was in the game in a non-save situation to work out some mechanical problems with his delivery.
But Wilson walked Bobby Abreu, hit Alex Rodriguez with a pitch, and after Xavier Nady struck out, Sexson blasted his 15th career grand slam.
Eddie Guardado got three outs for his third save in three chances. Guardado polished off the save by getting A-Rod to ground into a double play.
Harrison (3-2) allowed two runs and five hits in 6 1-3 innings. He started the night with a 7.40 ERA. He shut out the Yankees on three hits in the first five innings of his sixth major league start with the help of three double plays before Derek Jeter's sixth-inning sacrifice fly got the Yankees on the board.
In the first, Yankees starter Andy Pettitte (12-9) issued a two-out walk to Michael Young, and Hamilton jump-started the Texas offense with a two-run shot to pad his major league-leading RBI total to 108.
Pettitte allowed five runs and six hits in five-plus innings.
Rookie Chris Davis had a career-high four RBIs for Texas, three on a bases-loaded double in the seventh to stretch the lead to 8-2.
Marlon Byrd added three hits for the Rangers, who've won six of their last eight to move six games over .500 (60-54) for the first time this season.
Notes: Home plate umpire Alfonso Marquez warned both dugouts after Yankees reliever Jose Veras hit Hamilton with a pitch in the eighth. In the top of the inning, Wilson plunked Alex Rodriguez and Jamey Wright hit Melky Cabrera with a pitch. Harrison also hit A-Rod in the second inning. ...Sexson had his first homer since being signed by the Yankees on July 18. ...Rangers RHP Vicente Padilla returned to his native Nicaragua to attend to a family matter. Padilla is expected to rejoin the team for his scheduled start Saturday night in Baltimore. ... Yankees LF Hideki Matsui hit in a batting cage at the team's Tampa facility on Tuesday and remains hopeful he can return from a left knee injury before the season ends. He's been out since June 22. If Matsui can come back, he'll most likely have to play with a knee brace. ...Yankees RHP Carl Pavano will make a rehab start Thursday night for Double-A Trenton. The oft-injured right-hander is trying to come back from reconstructive elbow surgery. Pavano last pitched in the majors in April 2007, and has made just 19 starts since signing a four-year contract worth nearly $40 million contract with the Yankees in 2005. ...Texas DH Milton Bradley missed his seventh straight start due to a strained left quad.