By Bryan Hoch / MLB.com NEW YORK -- Alex Rodriguez connected for a game-tying two-run home run off Jonathan Papelbon and Marcus Thames won it with a two-run blast as the Yankees defeated the Red Sox, 11-9, in a wild finish on Monday at Yankee Stadium. Trailing by two runs heading to the ninth, Brett Gardner greeted Papelbon with a double to left field. Mark Teixeira moved the runner up with a flyout, and A-Rod connected with a monumental two-run shot into the Boston bullpen, his 588th career home run. Francisco Cervelli was hit by a two-out fastball and Thames connected for the game-winning homer, the Yankees' first walk-off victory of the season, earning him a celebratory whipped cream pie in the face from A.J. Burnett. The rally came after Kevin Youkilis and Victor Martinez belted back-to-back home runs off Chan Ho Park in the eighth inning, giving Boston their first lead of the game, with Martinez clubbing his second homer of the game. The Yankees jumped on Daisuke Matsuzaka for five runs in a 32-pitch first inning to grab a commanding lead, but the Red Sox worked long counts and used the long ball to claw back against Yankees starter Phil Hughes. Hughes had allowed six runs in 39 innings all year, a 1.38 ERA, but the Red Sox balanced the stats with five runs. Hughes was going strong into the fifth, when J.D. Drew made it a ballgame again by crushing a three-run homer off the right-hander, cutting Boston's deficit to one run. Adrian Beltre also touched Hughes for a run-scoring single in the second inning and David Ortiz beat the shift with a long solo home run into the second deck in right field in the fourth, his seventh. Hughes finished walking one and striking out three in a six-hit, 104-pitch outing. Thames gave the Yankees additional padding in the fifth with a run-scoring double to left, just missing a home run and making it 7-5. Yankees lefty Boone Logan served up Martinez's first homer in the sixth to make it a one-run game again.