A man was carried off on a stretcher after a nearly four-hour standoff with police in San Francisco's Tenderloin neighborhood Wednesday, and city officials are crediting new police training for the peaceful ending to a volatile situation.

The incident was reported at 2:12 p.m. in the area of Jones and McAllister streets just off of Market Street, Officer Giselle Talkoff said. It involved a man who was armed and in an apparently altered mental state, according to police.

The man was threatening to do harm to himself and made several statements to the effect that he wanted to die and police to take his life, police said.

Officers reportedly fired beanbag rounds at the man, and he fell to the sidewalk. For nearly four hours, the suspect remained face-down, refusing to show officers his hands to prove he wasn't holding a weapon.

Acting police Cheif Toney Chaplin credited new officer training for their ability to resolve the situation.

"The officers did what they've been training to do for the last 18 months, and that is they created a safety pocket," Chaplin said. "They backed up, they created time, they elongated this entire situation to get people to the scene to de-escalate this thing.

"We would have stayed out here until tomorrow if we'd had to," Chaplin added.

Police, who said around 6 p.m. that they recovered the suspect's handgun and ammunition at the scene near Hibernia Bank, added that he was being treated by medical personnel.

San Francisco PD

Market and Seventh streets were closed to both vehicles and pedestrians around 2:45 p.m. as police negotiated with the alleged suspect. People were urged to avoid the area.

Muni officials tweeted that bus service in the area was being rerouted and commuters should expect delays.

An eyewitness who was walking toward Market and Seventh streets around 2:15 p.m. told NBC Bay Area she saw heavy police presence in the area.

"When I got to Market and Seventh streets, I saw a man lying on the intersection of Jones and Market – he didn’t have a shirt on and there was a bike lying on the corner," the eyewitness said. "A lot of cops were standing behind a police car with their guns drawn at him.

"He was just lying there, not moving or anything. He just had shorts on. The cops just moved further and further away until you couldn’t see him any more."

The eyewitness, who was still at the scene at 4:15 p.m., said a man at the scene of the standoff, who identified himself as the suspect’s cousin, said the suspect was 36 years old and may have some mental health issues.

The eyewitness said she saw a SWAT team arriving on the scene and a hostage negotiator talking to the suspect.

San Francisco police tweeted at 3:56 p.m. that they had not discharged any firearms during the standoff.

"The handling of the situation today is a reflection of the emphasis that we put on de-escalation training in recent months," Mayor Ed Lee said. "We are making critical investments to rebuild trust with our communities and are changing out our police officers handle conflicts on our city streets."

Bay City News contributed to this report.