SAN FRANCISCO (AP) — Matt Cain raised his arms and waved his cap, fighting off tears amid a standing ovation as he walked off the mound for the last time Saturday.

Cain's decorated 13-year career came to an end with him pitching five shutout innings in the San Francisco Giants 3-2 loss to the San Diego Padres.

The home crowd at AT&T Park saluted the right-hander, a cornerstone of the Giants' championship era who pitched the only perfect game in franchise history. Cain took a curtain call and exited with a 1-0 lead.

"It was definitely an emotional roller-coaster as you walk out onto the field and take the bullpen mound," Cain said. "The first couple of innings were all adrenaline, the last three were just on the guys and the fans, the fans just willing me along."

Cain gave up two hits, struck out four and walked one. He made his last start a day ahead of his 33rd birthday and at the close of a $127.5 million, six-year contract.

"I think we'll look back at this game as another great memory we have of Matt Cain, from the perfect game to his postseason pitching," Giants manager Bruce Bochy said. "A lot of those great games that he threw, I'll look at this game too, at what he did to finish up."

Beset by injuries in recent years, Cain has said he couldn't imagine pitching for another team. The three-time All-Star finished 3-11 with a 5.43 ERA this year.

Cain pitched the clinching game of the 2012 World Series and is among four current players on the team who were part of the Giants' three World Series championships over a five-year period. Madison Bumgarner, Buster Posey and Pablo Sandoval are the others.

Cain hugged Posey on the field, and was greeted by Bumgarner in the dugout.

Making his 342nd start in a career that began with the Giants in 2005, Cain threw 73 pitches in his first game in September.

Cain worked 2,085 2/3 innings, and started the All-Star Game in his best year of 2012. He was 16-10 with a 2.79 ERA that season and placed sixth in the NL Cy Young Award voting. His perfect game came that June against Houston.

During his prime, Cain established himself among the game's top clutch performers, going 4-2 with a 2.10 ERA in eight career postseason starts. He didn't allow an earned run in 21 1/3 innings in the 2010 postseason.

Cain missed the Giants' run to the 2014 title after having bone chips removed from his right elbow. Elbow, arm and hamstring injuries limited his workload and effectiveness the last four years of his career.

Padres players joined in on the ovation when Cain left the game.

"You respect an opponent, especially when he's done it with class," Padres manager Andy Green said.

Wil Myers hit his 30th homer off Giants reliever Reyes Moronta in the top of the sixth to tie it. Myers has six home runs in eight games at AT&T.

The Padres rallied from a 2-1 deficit in the top of the ninth on Austin Hedges' two-out, two-run double off Sam Dyson (3-4), who blew his third save in 17 chances.

Buddy Baumann (2-1) pitched a scoreless eighth and closer Brad Hand worked the ninth for his 21st save.

TRAINER'S ROOM

Padres: RHP Carter Capps underwent surgery to address thoracic outlet syndrome earlier this week. "Everything went as it should," Green said. "The expectation is that he's going to be ready to go when spring training rolls around."

UP NEXT

Padres: RHP Luis Perdomo (8-11, 4.65 ERA) is 1-3 with a 4.43 ERA over his last four starts. He's 2-0 with a 3.55 ERA in eight career starts against the Giants.

Giants: RHP Johnny Cueto (8-8, 4.43) is 8-4 with a 3.09 ERA in 14 career starts against the Padres.

___

More AP baseball coverage: https://apnews.com/tag/MLBbaseball