SAN FRANCISCO, June 13 - Pitcher Matt Cain tossed the first perfect game for the San Francisco Giants on Wednesday, baffling the Houston Astros in a 10-0 shutout, that sparked pandemonium on the field and in the stands.

Cain became just the 22nd pitcher in Major League history to pitch a perfect game, achieving the feat in front of his home crowd in San Francisco.

The 27-year-old Cain struck out 14 batters as he mowed down the Astros' lineup, retiring each of the 27 batters he faced. The 14 strikeouts is a tie for the most during a perfect game.

Cain was in total command and sealed the feat when Jason Castro grounded out to third base to set off the celebration at the mound where the pitcher was mobbed by his team mates.

It was the fifth no-hitter thrown in the majors this season and the second perfect game. Philip Humber pitched a perfect game for the Chicago White Sox on April 21.

Virtually no-one left the stadium as Cain worked his way through the innings, with many in the crowd biting fingernails and sticking with baseball tradition refusing to even discuss the possibility of a perfect game as he edged closer to the ninth inning.

The Giants' right-hander got plenty of help from his defense, including a spectacular diving catch from right fielder Gregor Blanco in the seventh inning.

Cain's 125-pitch masterpiece improved him to 8-2 on the season.

(Writing by Jahmal Corner in Los Angeles; Editing by Greg Stutchbury)