Updated

Andy Pettitte was great in his last scheduled start at Yankee Stadium, but the San Francisco Giants spoiled his day and the Yankees' celebration of Mariano Rivera by dealing New York a crushing blow to its playoff hopes with a 2-1 victory.

The Yankees held a lavish pregame ceremony for the retiring Rivera and New York held a 1-0 lead behind five brilliant innings from Pettitte. It appeared to be setting up for another save from the Hall of Fame closer, but the Giants picked up a run in the sixth and another in the eighth.

Ehire Adrianza connected for his first major league homer off Pettitte in the sixth and a Tony Abreu RBI double in the eighth against David Robertson gave the Giants the lead and helped them salvage the finale of the three-game set.

The Yankees fell four games behind Cleveland for the final AL wild card spot and are also 4 1/2 games behind Tampa Bay, which holds the top wild card berth and will visit Yankee Stadium for a three-game series starting Tuesday.

Pettitte (10-11) left the field to a thunderous ovation after surrendering a leadoff double to Pablo Sandoval to start the eighth inning with the game tied at 1-1. He tipped his cap to the fans and was greeted by longtime teammate and injured captain Derek Jeter before reaching the dugout. The fans then continued chanting his name and he acknowledged the crowd with a curtain call.

Robertson, though, was unable to pick him up, as a grounder to first by Hector Sanchez advanced pinch-runner Nick Noonan to third and he scored easily on a double into right field by Abreu.

Rivera entered the contest and got five outs, but the Yankees could not scratch out a run to tie the contest despite having a great chance in the eighth inning.

Alex Rodriguez started the home eighth against Santiago Casilla with a single and pinch-runner Zoilo Almonte was stopped at third on a double into the right field corner by Robinson Cano. Alfonso Soriano then hit a hard grounder into the hole between short and third. Noonan made the stop and threw Almonte out at home.

After Curtis Granderson struck out, Eduardo Nunez singled into left field. Cano raced around third, but was gunned down at the plate by Juan Perez.

The Yankees went quietly in the ninth against Sergio Romo, who earned his 36th save. Javier Lopez (4-2) was credited with the win, striking out the only two batters he faced in the seventh after taking over for starter Yusmeiro Petit, who surrendered just a run on six hits with a pair of walks and seven strikeouts over 6 1/3 innings.

"To compete on the same mound against Mariano -- he toed the rubber before I did today," Romo said. "It was pretty sweet for me."

Mark Reynolds gave Petit his only blemish of the game with a leadoff homer in the third inning.

Pettitte retired the first 14 batters, then walked Sandoval before Sanchez flied harmlessly to left. He set down the first batter of the sixth before Adrianza drilled a pitch into the left field seats to tie the game.

The Yankees threatened in the seventh when Nunez led off with a single and Brendan Ryan added a one-out base hit. The runners moved up on a passed ball with Lopez pitching to pinch-hitter Vernon Wells, who eventually struck out. Ichiro Suzuki also fanned to keep the game tied.

Pettitte was charged with both runs on just two hits and one walk with six strikeouts in seven-plus innings.

The day began with a celebration for Rivera, who had his No. 42 retired by the club in the famed Monument Park.

"It was a great day," said Rivera after the contest. "I didn't know what to feel, but when I got to the monument and saw my number retired, it was emotional.

"Today was a big day for me and my family. I appreciate what the organization did and how the fans supported me, but in the end it wasn't that great because we lost the game."

Game Notes

The Yankees outhit the Giants, 9-4, but were just 1-for-7 with runners in scoring position ... Pettitte, whose 218 wins with the Yankees rank third in club history, is slated to make one more start next weekend when New York closes the season in Houston ... Among the former Rivera teammates to join the pregame ceremony were David Cone, Hideki Matsui, Tino Martinez, Paul O'Neill, Bernie Williams and Jorge Posada, as well as former manager Joe Torre and John Wetteland -- the man who preceded Rivera as Yankees closer.