Updated

The Giants team that became so known for its torturous outcomes on the way to an unthinkable World Series title last fall pulled off another dramatic victory in its home opener — and how fitting that was.

San Francisco raised the flag and St. Louis dropped the ball.

Aaron Rowand hit a game-winning single off the left-field wall with the bases loaded in the 12th inning and the Giants celebrated raising the World Series flag with a 5-4 victory over the Cardinals on Friday.

"It's obvious we're not retiring torture," manager Bruce Bochy said with a grin. "This was a very emotional day, all day. And the game was an emotional roller coaster. We were looking at a tough loss there and these guys battled back. It was quite a ballgame for our home opener."

First baseman Albert Pujols dropped what would have been an inning-ending grounder by Andres Torres with two outs in the 12th. That after the Cardinals should have turned a double play to get out of the inning but Nate Schierholtz beat the relay throw. Torres reached on the error by Pujols and advanced to second on defensive indifference. Brian Tallet (0-1), the sixth Cardinals pitcher, intentionally walked Freddy Sanchez to load the bases. Rowand then drove a pitch to deep left-center, capping a long, festive home opener that lasted 4 hours, 24 minutes.

Dan Runzler (1-1), the Giants' eighth pitcher, tossed a 1-2-3 12th for the victory.

By the time this one ended, an elaborate 50-minute pregame ceremony seemed like so long ago. The Giants raised their first World Series flag since the New York team did so on April 14, 1955, at the Polo Grounds.

"Everyone just grinded it out together," Runzler said. "It was a lot of fun. It reminded me of last year."

This game featured rallies by both teams, some quirks and even Sunday St. Louis starter Kyle Lohse as a pinch-hitter in the 10th. It marked the eighth time in San Francisco history the Giants went extra innings in their home opener. They are 6-2 in those.

The game marked the longest by innings in a defending World Series champions' home opener since the Yankees lost 3-1 to the Oakland Athletics in 12 innings, on April 11, 1997, according to STATS, Inc.

The Cardinals rallied in the ninth on Ryan Theriot's two-run, two-out single against 2010 majors' saves leader Brian Wilson. Theriot fell behind 0-2 and then singled through the left side of the infield to end a 12-pitch at-bat.

Wilson was replaced by Ramon Ramirez, and in the process glared at plate umpire Bruce Dreckman and angrily fired off words toward him. Wilson threw 15 balls among his 34 pitches.

"I did it. It's not the first time I've snapped," Wilson said of his temper. "I got kind of hot there for a second. Oh well, it's what happens. You get caught up in the moment and you get a little angry. I jaunted, vented, got it out of my system, then sat downstairs and watched the Giants come back."

But St. Louis closer Ryan Franklin couldn't hold a lead either. He gave up Pablo Sandoval's tying, two-out single in the bottom of the ninth and blew his second save of the season in three opportunities after blowing two saves all of last year.

This marked the Giants' second straight year going extra innings in their home opener. They beat the Braves 5-4 in 13 innings in 2010.

Miguel Tejada hit his first home run for the Giants with a third-inning solo shot and Pat Burrell — one of those castoffs and misfits who helped the franchise capture its first championship since the New York team in 1954 — also had a solo drive off St. Louis starter Jake Westbrook. Freddy Sanchez added an RBI double for San Francisco, which put starter Jonathan Sanchez in position to win before Wilson blew it.

Jonathan Sanchez struck out seven and walked two in five innings, allowing one earned run and four hits. The lefty started his second straight home opener on a day of fanfare at AT&T Park. The Giants will receive their rings before Saturday night's game.

Bochy, for one, was eager to get through all the hoopla of this busy weekend so his team can focus completely on baseball and winning.

The Giants went 2-4 on their season-opening road trip against NL West rivals Los Angeles and San Diego.

Wilson — the bearded closer — made his way to the mound to a standing ovation. He then allowed a walk, infield hit and plunked pinch-hitter Jon Jay to load the bases with two outs in the ninth. That brought up Theriot.

"We fought back hard. We fought back off their best guy in the bullpen," Franklin said. "It says a lot. Maybe that can be a thing that will carry over and we can start doing some good things."

The Cardinals kicked off a 10-game road trip against the NL West with another quiet day at the plate until late.

St. Louis, which applauded the reigning champs despite having to stand on the first-base line for a prolonged period after being introduced before first pitch, scored more than three runs for the first time this year. That ended the team's longest such streak since 1919.

"We just haven't put it together yet. Right now we are 2-5 and by the St. Louis Cardinals' standards that's unacceptable," Tallet said. "We're going to be good. We're going to win ballgames. We just have to put the pieces together."

The Giants recognized longtime fan Bryan Stow, who was attacked after the team's opener at Dodger Stadium last Thursday and remains hospitalized in Southern California with brain trauma. Stow's picture with his two children — who were in attendance — was shown on the main center-field scoreboard and it generated cheers of "Beat L.A.!" The Dodgers arrive for a three-game series starting Monday.

Hall of Famer Willie Mays presented Bochy with the folded-up World Series flag, which the skipper passed down the line so each of his players could hold it briefly.

Wilson then ran the flag out to the wall in right-center, climbed a short ladder and hustled through the stands while escorted by security and police. The pitcher high-fived fans and helped put the banner on the flag pole as Queen's "We are the Champions" blared through ballpark.

"I respected them," Cardinals manager Tony La Russa said of all the waiting around during pregame festivities. "It was their day. We hung in there."

NOTES: Cardinals cleanup hitter Matt Holliday went through a pregame workout and took batting practice a week after undergoing an appendectomy. Holliday, who reported being pain-free afterward, was to be reevaluated afterward to better determine when he might be ready to return — which he hopes is in the coming days. ... Bochy plans to use Wilson a little bit more conservatively for now as he is just back from a strained left oblique muscle that landed him on the DL to start the season.