"There's a lot of nerves there," Headley said. "But I kind of stepped out of the box and I thought to myself, 'Why not? Why wouldn't this day go this way?' I was able to enjoy it."
The decisive hit came off right-hander Nick Tepesch, the ninth Texas pitcher of the evening, a starter pressed into duty as both managers had exhausted their bullpens.
Brian Roberts laced a one-out ground-rule double to right field, and Francisco Cervelli singled through the right side of the infield, setting up Headley's flare to left-center field.
Acquired earlier in the day from the Padres, Headley quickly shaved his beard in the cramped visitors' clubhouse at Chicago's Wrigley Field, packed a few bags and said goodbye to his old teammates before boarding a commercial flight bound for LaGuardia Airport.
Headley made his debut as a pinch-hitter in the ninth inning and was hitless in his first three at-bats, but he made a terrific leaping grab to take a hit away from Rougned Odor in the 10th, then walked off the hero.
His reward: an ice-cold Gatorade bath on the field.
"He's had a whirlwind of a day," Yankees manager Joe Girardi said. "He got traded, had to pack his stuff, get here and he gets a huge hit."
Jeff Francis was credited with the victory after recording three outs in the 14th inning, making his Yankees debut. Francis had been tossing in the bullpen, but this was his first game action since he was acquired from the Athletics on July 11.
"We've been in close games; the starter's been going deep into games," Francis said. "I really couldn't point to a time where I felt like I'd been passed over. You wait for your opportunity and try to make the best of it."
J.P. Arencibia put the Rangers ahead in the top of the 13th with a home run off left-hander David Huff, marking the first run of the game. The Yankees answered in the home half.
Brett Gardner greeted Joakim Soria with a double, advanced on a sacrifice and scored on Jacoby Ellsbury's single to right field. After another hit, Soria got Brian McCann to hit into an inning-ending double play.
Texas narrowly escaped a bases-loaded, one-out jam in the the 12th, with Scott Baker wriggling free by retiring Cervelli on a scorching lineout to third baseman Adrian Beltre and Headley on a broken-bat fielder's choice.
"Cervy hits that ball, and you can't hit a ball any harder," Girardi said. "If it's one foot to the left, he doesn't catch it. You just think, 'What are the chances?'"
In the ninth inning, Derek Jeter connected for a double, the 535th of his career, to surpass Lou Gehrig (534) and claim the all-time franchise lead.
Both bullpens were stellar. Matt Thornton, Adam Warren, Dellin Betances, David Robertson and Shawn Kelley combined to work scorelessly in relief of Chase Whitley, who blanked Texas over six-plus frames.
Whitley, who had not completed five innings in any of his previous four starts, scattered seven hits in one of his best outings of the year. Whitley walked none, striking out six.
"Maybe I found something today, I don't know," Whitley said. "It would be pretty cool to move forward with that."
Rangers rookie Nick Martinez held the Yankees to three singles over 5 1/3 scoreless innings, retiring 14 of the last 16 batters he faced. The Fordham product got some help from center fielder Leonys Martin, who took an extra-base hit away from McCann with a leaping grab near the wall in the second inning.
One night after the Yankees committed five errors, the Rangers exhibited miscues of their own. Robinson Chirinos ran Texas out of the fifth inning when he continued toward home on a two-out ground ball; in the 12th, McCann's soft pop to shallow left field fell untouched between three fielders.
"Crazy game. Pretty crazy," Texas' Elvis Andrus said. "Both teams, we didn't give up. In the end, they had more luck than us."
There was temptation to assure Headley that this was an aberration, that games in the Bronx are not all quite so lengthy or wild. But if you could assure the same outcome each time, it's a fair guess he wouldn't mind at all.
"A little chaotic; awesome, though," Headley said. "Obviously, you have mixed emotions when you've been at a place for as long as I've been in San Diego. But I couldn't be happier to be a Yankee. It's unbelievable. Can't even believe I'm saying that. A long day, but a great way to finish."