Forty people were arrested Wednesday night in San Francisco as street celebrations of the Giants’ third World Series win in five seasons devolved into drunken debauchery and occasional violence, police officials said Thursday.

As bonfires burned and people painted graffiti and set off fireworks, officers arrested 29 people on suspicion of being drunk in public. Three people were booked for an alleged assault and two were busted for illegal gun possession, police said.

“To the fans who came to San Francisco and celebrated like we’ve been there before, God bless ya, hope you had a good time,” Police Chief Greg Suhr said at a news conference. “To the clowns that came to San Francisco to act out, I guess you just don’t know what it’s like to have a good time without being a jerk, and we had a lot of them last night.”

Many of those arrested, Suhr noted, were from outside the city.

There were also two shootings after the baseball game, Suhr said. One person was shot in the arm near 21st and Valencia streets, and second person walked into San Francisco General Hospital with a gunshot wound that he said occurred near 16th and Bryant streets. However, police were unable to confirm that location through Shotspotter, the gunfire detection system.

An argument led to a stabbing near 21st and Valencia Streets, police said, with the victim suffering three wounds and being hospitalized in serious condition.

Suhr lamented the number of bottles thrown at police. Three officers were hospitalized after being struck, he said, but will recover. In addition, nine police cars were either tagged with graffiti or had windows smashed.

“There were as many bottles thrown at police officers as I can remember, and it is disgraceful,” Suhr said. “We’re fans too, and we’re out there doing our job.”

In the Mission District, business owners were picking up the pieces early Thursday and assessing the damage. Glee over the victory was tempered with frustration that, once again, some people couldn’t control themselves.

Amid a tableaux of shattered glass, graffiti and trashed streets in the Mission, merchants, city workers and residents were trying to make sense of it.

“There’s no way to stop it,” said Alex Delgado, 25, as he surveyed six damaged windows at a mixed-use condominium complex near 22nd and Mission streets. “If they win next year, it’ll happen next year.”

Kim Jung, 57, said he was upset that graffiti had been scrawled outside his diner near 20th and Mission. “I’m lucky there wasn’t any broken windows,” he said.

Jung said he was “happy” that the Giants won, but wondered aloud about why fans would veer into vandalism: “Why is it like that?”

Jamie Morganstern, 28, who lives on Valencia Street, said he found the damage disturbing but added, “I don’t know how you can prevent people from acting out.”

Zack Smith, 32, the co-owner of Southpaw BBQ and Southern Cooking at 18th and Mission, was also cleaning up graffiti. “It’s 7 a.m.,” he said. “I’d rather be at home, but life happens. It’s all good. I’m glad the Giants won.”

Smith said he had been at the bar until 1:30 a.m. to make sure everything was OK. He went home, went to sleep and came back to find the eatery damaged.

San Francisco Public Works employees were in the Mission Thursday morning assessing the destruction, taking pictures of buildings that had been hit with graffiti.

Hamed Aleaziz and Henry K. Lee are San Francisco Chronicle staff writers. E-mail: haleaziz@sfchronicle.com and hlee@sfchronicle.com Twitter: @haleaziz @henryklee