In a setting resembling a block party, scores of law enforcement officers for more than three hours Tuesday night avoided shots being fired from a home in Sangaree, then stormed it and apprehended the gunman.

Officers fired no shots during the Birmingham Drive standoff, but used a stun gun in a final showdown with the man who had threatened to take his own life, Berkeley County Sheriff’s Office spokesman Dan Moon said.

The standoff in the neighborhood between Summerville and Goose Creek began about 6:30 p.m., and at almost 10 p.m. Moon made his way through a street crowded with people and emergency vehicles and personnel to declare, “It’s over.”

“It was a good ending to the story,” he added. He said the man, whose name was not released, was being taken to a hospital. Why the man barricaded himself in his 227 Birmingham Drive home and fired rounds of shots to the outside isn’t yet known, Moon said.

He said the incident began after police checked on a man threatening suicide. He said the man was in the house by himself with a couple of dogs, with the lights off.

Some residents of homes nearest the gunman’s house were evacuated. Many joined the hundreds of other people who filled the street and porches and driveways during the night. Reporters and photographers mixed in the crowd, and occasionally rifle-toting deputies, including SWAT Team members, passed by.

Numerous times, people on the street heard clusters of shots in the distance, apparently coming from the barricaded home. Moon said the man fired from the front and rear of the home.

He said he doesn’t know how many shots the man fired, but added that no one was hurt.

For hours, Kevin Scarborough and Marita Bremel stood in a Birmingham Drive yard, talking to Scarborough’s son on a cellphone. Scarborough said his 19-year-old son stayed home during the ordeal, and being just a few doors from the home occupied by the gunman, he was able to phone and text-message events as they occurred.

While Scarborough talked to a reporter, he received a text message from his son saying authorities had rushed the gunman and taken him down. Minutes later, Moon made the official announcement.

Scarborough said he and Bremel had just begun an evening fishing trip when a neighbor phoned to tell them about the standoff. “We’ve been out here two hours, and I don’t like it,” Scarborough said about 15 minutes before the standoff ended.

Moon said negotiators spoke with the man on the phone and convinced him to come out. Officers approached the front door several times, but each time the man backed away from them and refused to come out.

Moon said the man texted his wife threatening to kill himself. She called deputies and asked them to check on him. When they did, the man started shooting out of the house.

Finally, Moon said, officers returned to the door and rushed the man as he backed away. The officers used a stun gun to subdue him, he said.

Moon estimated that 40 to 50 officers from Berkeley and Dorchester sheriff’s officers and Goose Creek and Summerville police came to the scene. Firefighters from several departments also were there.