ARLINGTON, Texas (AP) Brett Gardner got things started for the New York Yankees with a leadoff home run, then had three more hits after that.

Despite all that and Mark Teixeira's two-run homer in his return to the starting lineup, the Yankees sweated it out until the very end before Gardner caught a flyball near the warning track in left field with the bases loaded for a 12-11 victory at Texas and overcome a seven-RBI game by J.P. Arencibia on Tuesday night.

"It was a strange game, but it was great to get out of here with a win," manager Joe Girardi said. "It would have been a bad one to lose."

The Yankees never trailed after Gardner reached base twice in a seven-run sixth inning. They led 10-4 before Arencibia, already with two doubles and a solo homer, hit a grand slam in the seventh.

Texas scored twice off closer David Robertson, the fifth Yankees pitcher, and still had the bases loaded in the ninth after Elvis Andrus had a two-run single. Adrian Beltre hit a towering flyball that finally ended the game after 3 hours, 51 minutes.

"It was about as bad as you can suck and still get one of the better hitters in the game out and not lose the ballgame," said Robertson, who got his 27th save in 29 chances.

"If you look into that sixth inning, I don't think there were many people that thought we had a chance," manager Ron Washington said. "But we never quit, and we was one swing away with the right guy at the plate."

Arencibia struck out to start the ninth, but still was the first Texas player with four extra-base hits since Josh Hamilton's four-homer game at Baltimore on May 8, 2012. The last player in the majors with at least seven RBIs in a loss was Jonathan Lucroy in 2012, when Milwaukee fell to the Cubs, STATS said.

"Not enough," Arencibia said when asked to describe his game.

Brandon McCarthy (3-0) went six innings for the Yankees, who have won all four of his starts since getting the big right-hander in a trade from Arizona on July 6.

Teixeira, in his first start in nine games after a back strain, homered in the eighth to make it 12-8. He also walked three times and scored two other runs.

Gardner, who went deep twice Monday off Yu Darvish, led off against rookie Nick Martinez (1-7) with his 13th homer. He added his second double to start the sixth and scored the first run in that rally.

"He was hitting the ball hard before but getting outs," Girardi said. "Now he's hitting it out and hitting it down the lines."

TRAINER'S ROOM

Yankees: RHP Michael Pineda (shoulder), out since early May, threw 45 pitches in a bullpen session and is set to start an injury rehab assignment Sunday. Infielder Kelly Johnson (strained left groin) is expected to be ready to play when eligible to come off the DL on Aug. 7.

Rangers: Nick Tepesch pulled himself out of his last start Saturday night because of left knee soreness, and now Texas will skip his next turn in the rotation Friday as a precaution. Jerome Williams starts Friday at Cleveland.

ON DECK

Yankees RHP Hiroki Kuroda, 2-2 with a 2.08 ERA in five career starts against Texas, pitches against Colby Lewis in the rubber game of the three-game set. The Rangers will try to end a string of seven consecutive series losses since taking two of three against Minnesota on June 27-29, also the last time they won consecutive games.

GREAT GLOVE

Gardner had a running, sliding catch on a ball that Shin-Soo Choo sliced into the left field corner leading off the third.

I GOT IT - NOT

The final run in the Yankees sixth scored after Gardner's flyball into the right-center field ended up a three-base error. Right fielder Alex Rios was calling for the ball when he reached for it, but closed his glove too soon. The ball ricocheted off the back of his glove and then off the head of center fielder Leonys Martin, who was also in pursuit. Martin said he never heard Rios calling for it.

JETER JUSTICE

Derek Jeter was initially called out in the sixth after his chopper that was deflected by Martinez and led to a barehanded grab and throw by shortstop Andrus. Girardi challenged, and replay showed that Jeter was safe for his second hit of the game and 3,422 of his career.

Almost Done!

Please confirm the information below before signing up.

{* #socialRegistrationForm_pubsports *}
{* socialRegistration_firstName *}{* socialRegistration_lastName *}{* socialRegistration_emailAddress *}{* socialRegistration_displayName *}
By checking this box, I confirm that I have read and understood each of the website terms of service and privacy policy and that I agree to be bound by them.