Profar's three-run homer in the first that just cleared the 8-foot wall in center put the Rangers ahead to stay against Domingo German (0-2). Guzman started the fourth with a liner into the right field seats, making it 6-1 only a few batters before the Yankees starter came out.
New York, a big league-best 31-14, had won 22 of its previous 26 games and was coming off a three-game stretch with 14 homers and 28 runs.
The Yankees' Aaron Boone got his first ejection as a big league manager for apparently arguing balls and strikes while Gary Sanchez was batting in the sixth. After the high strike for an 0-2 count that led to Boone's ejection by plate umpire Pat Hoberg, Sanchez drew a walk. He left in the middle of the inning, apparently because of a cramp.
Hamels (3-4) struck out seven and walked two in his first start in 11 days. The lefty was scratched from his precious turn because of neck stiffness.
Keone Kela worked a perfect ninth for his ninth save in as many chances, the Rangers' first save since May 11 when he closed out a 1-0 win at Houston in Hamels' prior start.
Texas had provided only one run in support for Hamels in four of his previous five starts and five of the last seven. Opponents hit only .206 in his last six starts before the Yankees went 4-of-25 (.160) against him.
Rookies Gleyber Torres and Miguel Andujar hit solo homers off Hamels. Torres, who homered twice in the series opener Monday, has seven homers in his first 26 career games.
Austin Romine, who replaced Sanchez, hit a two-run homer in the eighth but the Yankees fell short of becoming the first team to homer four times or more in four consecutive games.
Texas led 5-0 after scoring twice without a hit in the second, when German hit a batter, walked two and had three wild pitches.
There have been 25 wild pitches and seven passed balls when Sanchez has been behind the plate this season.
Yankees: Boone said “there is a shot” that 1B Greg Bird, who has 20 homers in his 94 career games, could make his season debut this weekend at home. Bird has been on the disabled list all season recovering from right ankle surgery and is rehabbing at Triple-A Scranton/Wilkes-Barre.
Rangers: SS Elvis Andrus (broken right elbow) began doing dry swings with a fungo bat. 3B Adrian Beltre (strained left hamstring) took some groundballs at an easy pace for the first time since re-injuring his hamstring May 13. Former two-time NL Cy Young winner Tim Lincecum (blister right finger), who could make his Texas debut as a reliever as early as next week, had a 42-pitch rehab appearance Monday.
New York will try to win its fifth consecutive road series in the finale. Yankees lefty CC Sabathia's 2,879 career strikeouts are tops among active pitchers, and his 239 wins are second only to Rangers right-hander Bartolo Colon, the loser in the series opener. Doug Fister (1-4) pitches for Texas.