SAN FRANCISCO -- Matt Cain thought about it all right, well aware he had yet to allow a baserunner as he piled up outs. The Giants ace never has thrown a no-hitter at any level, so he pondered this might just be his day to do it -- and with all the hype of the home opener, no less.
He nearly pulled it off, until the opposing pitcher spoiled a most impressive bid. James McDonald became the lone baserunner of the afternoon for Pittsburgh.
Cain tossed a one-hitter, allowing only a two-out single in the sixth inning to McDonald during a near-perfect performance Friday as the San Francisco Giants beat the Pirates 5-0 in their home opener.
Cain knew something else as he rolled along: McDonald is a capable hitter, even if his numbers say otherwise.
"I was definitely aware of it but I'm thinking there, 'I'm behind in the count 2-1 but I'm throwing something to the outer third of the plate," Cain said. "He put a good swing on it. He did his job. He can hit. I knew that going into it that he can swing the bat well."
Cain struck out 11 and produced just the gem the Giants needed as they returned from a rough road trip for a homestand that also includes three games with the Phillies.
Pitching 11 days after signing a new $127.5 million, six-year contract -- a record for a right-hander -- Cain worked ahead all afternoon and faced only one three-ball count while retiring the first 17 batters in order.
Cain finished an impressive 106-pitch outing in all of 2 hours, 10 minutes.
McDonald, a career .069 hitter coming into the game, hit a sharp single to left field. He felt a little strange being the one to break up the perfecto.
"You think about, it's like, 'Man, the pitcher stood in his way for a perfect game," McDonald said.
Fans in the sellout crowd of 41,138 jumped to their feet to give Cain a warm ovation when McDonald reached base.
Cain (1-0) pitched his third career one-hitter, his fifth shutout and his 14th complete game.
"It took a couple innings. I was just kind of getting back into the rhythm of pitching in the wind and the weather," Cain said. "It definitely pumps you up when you get the home opener and the fans are coming out."
The Giants celebrated their 1962 World Series team and a large cast of Hall of Famers with an impressive day -- with blue skies and sun to boot after a huge rain and thunderstorm overnight and into Friday morning threatened to mess with the festivities.
Cain, who has long been the team's hard-luck loser because of a lack of run support, went the distance when San Francisco closer Brian Wilson wasn't available after he worked a 32-pitch ninth inning a day earlier in a 4-2 win at Colorado.
"What a day by Matt," manager Bruce Bochy said. "We've all seen him locked in like this. He was as good as he's been."
McDonald produced his seventh career hit but Pittsburgh dropped its fourth straight game after being swept at Dodger Stadium.
McDonald (0-1) allowed three runs on six hits in 5 2/3 innings, struck out one and walked three.
Huff hit a two-run homer in the eighth. Nate Schierholtz had a pair of singles and drove in a run in the sixth for the Giants, who came home from a 2-4 road trip in which they were swept in three one-run losses at defending division champion Arizona before taking two of three from the Rockies at Coors Field.
Posey wound up 1 for 3 with the double and a walk in his long-awaited home debut in front of the fans who have supported him every step of the way in his long journey back from three torn ligaments in his left ankle and a broken bone in his lower leg.
Tyler Stow, the 13-year-old son of beaten Giants fan Bryan Stow, threw out the ceremonial first pitch in place of his dad under the coaching of Giants reliever Jeremy Affeldt. Bryan Stow, sitting in a wheelchair accompanied by his mother, Ann, was shown live on the main center-field scoreboard as if handing the ball to his son while wishing the boy good luck.
"It was very heartfelt to see him out there," Cain said.
Cain's last shutout came on June 8, 2010, at Cincinnati. It also marked the third time he pitched a shutout allowing only one hit. ... Struggling San Francisco 1B Brandon Belt didn't start for the fourth straight game. He's 1 for 11 with five strikeouts in four games. ... Bochy expects Wilson ready to go Saturday. ... The Giants sold out for the 85th straight time, a streak that began with the final three regular-season games of 2010. ... Garrett Jones played his first game of the season in RF for Pittsburgh.
DJ LeMahieu's not his team's biggest star, but he's been the glue of Colorado's clubhouse. Still, amid a frenzied playoff chase, his future in Denver could be in doubt.
The American League East race is over. The key now for the Bombers: Win the first wild-card spot and then decide who's going to pitch.
Check out some of the nastiest pitches that stunned batters in the box including Adam Wainwright's curveball and Jordan Hicks' fastball.
Wei-Yin Chen will make his final home start of the season Friday in a year in which he has been dominant at Marlins Park.
The Tampa Bay Rays have even less room for error to keep their postseason hopes alive after dropping the opener of a four-game series against the Toronto Blue Jays in shocking fashion Thursday night in Toronto.
Angels catcher Francisco Arcia becomes the first player in MLB history to catch, take the mound and hit a home run in Los Angeles' 21-3 defeat in Oakland.