Tens of thousands of fans went bonkers Wednesday when the Giants finished off a do-or-die World Series Game 7 to win their third championship in five years.

It was pandemonium at Civic Center Plaza, where throngs in orange and black partied on the lawns on either side of the center and spilled onto U.N. Plaza after watching the game’s dramatic end on a jumbo screen.

A New Orleans-style jazz band formed after the final out and held an impromptu parade in front of the San Francisco Library and Asian Art Museum, with at least 100 people dancing along and shouting. Fans stood shoulder to shoulder screaming and cheering amid a horn-honking hootenanny outside bars in the Mission, South of Market and throughout downtown.

The excitement spread across the city.

“This is fun,” said Kevin Yarbrough, who wore full Pablo Sandoval regalia to Pedro’s Cantina, South of Market, including a huge panda head, fuzzy pants and bear slippers. “The city has not been able to breathe. Torture is kind of what we’ve come to know.”

The crowds were mostly peaceful — but there were early signs of trouble. One person was hospitalized with a gunshot wound to the arm as the celebration began, according to police.

Exuberant revelers shut down the intersection of 24th and Mission streets within a half-hour of the end, chanting “Let’s go Giants!” and “MadBum, MadBum, MadBum!”

Police quickly showed up with riot helmets stored on their belts and batons at the ready, but the police presence had little effect on the joyous party. Champagne bottles popped, fireworks went off and a small trash fire briefly ignited.

“I feel beautiful,” said Daryl Luppino, 54, who pulled over in his truck to celebrate as the Giants closed it out. “These boys deserve this.”

On King Street, across the street from AT&T Park, hundreds of Giants fans poured out of bars like Pete’s Tavern and Polo Grounds. They had shelled out $10 cover charges, but it was all worth it on this night.

“We want to rage in the streets when the day is done,” said Devin Wall, who was sitting at a table at Lucky Strke that was covered with beers and shots. “Two years ago it was crazy here. Tonight I expect the same.”

Mayor Ed Lee announced shortly after the game that a parade will be held for the Giants at noon Friday down Market Street to Civic Center Plaza.

“The San Francisco skyline is awash in orange,” Lee said in a statement. “I congratulate our world champion San Francisco Giants after another spectacular World Series victory.”

The game itself was as tense as they come. Cheering patrons crammed into virtually every San Francisco establishment that had a television set, oohing and ahhing at every swing. As the game began, lucky charms, superstitious routines and raw gumption had already helped many fans forget the previous night, when the Royals won 10-0 and tied the Series at three games apiece.

The crowds celebrated when the Giants took a 3-2 lead in the fourth inning — but not everyone was sure it would hold up.

“That was the hit that turned this game in our favor,” shouted Jeremy Lee, 23, of San Jose, after Pablo Sandoval beat out a single. “This is the inning, baby.”

As the game reached the late innings — and Giants ace Madison Bumgarner mowed down one Royals batter after the other — chants of “MVP” rang out on the rectangular Civic Center plaza, even among the dancers in a drum circle.

“The series was kinda scary at the beginning,” said Esther Picazo Barrbera, 50, as she stood decked out in Giants gear outside the Irish pub Napper Tandy in a crowd of shouting, beer-soaked fans. “But I always believed in my Giants.”

“All the tables are taken and the bar stools, too,” said Lawrence Alfred, as he checked IDs at the door of the Phoenix, an Irish pub on Valencia Street, where he was in charge of tamping down the drunken rowdiness.

San Francisco-based filmmaker James Moon said the team had “worked out its weaknesses” during the lopsided defeat on Tuesday. He said the key was for Giants fans to stay positive and behind the team no matter what.

“Our fans can be a little wine and cheese sometimes - they need something a little special to get up and cheer,” he said.

San Francisco Police Officer Gordon Shyy, a department spokesman, said police weren’t taking any chances Wednesday night.

Patrols were beefed up by 15 percent to 20 percent for Game 7, and fans caught with alcoholic beverages out on the streets were being forced to pour them out. That kept the cops busy, with many vendors selling beer along with the water, hats, posters, lighters and Giants bracelets.

In 2012, the Giants’ World Series victory over the Detroit Tigers ended in a small riot late at night, with a Muni bus set on fire, causing $700,000 in damages. In both 2010 and 2012, fans near AT&T Park smashed bottles and set bonfires in the street.

J.K. Dineen, Kale Williams, Evan Sernoffsky and Peter Fimrite are Chronicle staff writers. E-mail: jdineen@sfchronicle.com, kwilliams@sfchronicle.com, esernoffsky@sfchronicle.com, pfimrite@sfchronicle.com