A gunman armed with an AK-47-style weapon burst into a Planned Parenthood clinic in Colorado Springs Friday, shooting at police from inside the building during the ensuing five-hour standoff.

Three people, including a police officer, died during the incident, Colorado Springs Police Department Lt. Catherine Buckley said. Nine others, including five officers, were wounded. All nine were in good condition, Buckley said.

Memorial Hospital in Colorado Springs said Saturday of the four patients it had received, two were discharged. There was no immediate word on the patients at other hospitals.

PHOTOS: Gunman Shot Three Dead in Colorado Springs

The slain officer was identified as Garrett Swasey, 44, of the University of Colorado-Colorado Springs police department. He was married and had a son and daughter, according to the website of his church, Hope Chapel in Colorado Springs.

Colorado Springs Shooting Suspect Robert Dear. Colorado Springs Police Department

The gunman, who police named as 57-year-old Robert Dear, walked out of the facility just before 5 p.m. local time and surrendered.

Gunshots were first reported near the facility on Centennial Boulevard in Colorado Springs at around 11:38 a.m. The shooter began firing in the parking lot and then entered the building, a law enforcement official told NBC News. The shooting unfolded during a regular working day, as patients waited for appointments and staff members attended to them.

"I heard everyone in the lobby screaming ‘Get down! Get down!’ and then I saw a gunman walking with a shotgun just shooting randomly outside of Planned Parenthood," Kentanya Craion said after getting out of the building.

The gunman "seemed calm, but crazy," she added, describing the man in a hunter's jacket and hat as "mumbling and ranting while he was shooting."

She said she ran into an open room with two others where they barricaded themselves inside for about five hours as they heard shots ring out.

Authorities soon tapped into the building's video surveillance system, and were able to monitor the gunman's movements, officials said.

Colorado Springs Mayor John Suthers told NBC News that police watched for several hours on live video as the suspect hunkered down inside.

The officers watching passed along sketches of the building layout to teams inside, Suthers said. And as the gunman moved about the building, police rescued some of those trapped inside the other areas.

Other officials told NBC News that several people escaped during the ordeal thanks in part to police personnel who rammed the side of the building with a truck.

Police officers who responded were shot at with officers describing how they were "pinned down" by gunfire.

Police announced Saturday that they had cleared the building, which they had continued to inspect overnight to make sure several unidentified items the gunman brought with him were not dangerous.

Investigators were also trying to identify an item left in what is believed to be the suspect's car, a law enforcement source said. The device appeared to be a propane tank with wires sticking out, the source said.

University Chancellor Pam Shockley Zalabak said Swasey, the slain officer, was responding in support of city police to the active shooter situation when he was killed.

"We mourn the loss of a very brave police officer," Mayor Suthers said.

UCCS police officer Garrett Swasey was killed. University of Colorado Colorado Springs

"While this was a terrible, terrible tragedy, it could have been much worse but for the actions of the first responders, particularly the police officers involved," Suthers told reporters.

"They were able to get people out of the building safely, and they were able to make sure that the perpetrator was isolated in a place where there could be communication back and forth about where he was," Suthers said.

Joan Motolinia said his sister was in the clinic when gunshots were heard. "She called me and she was telling me that there was a shooting — I heard the shooting," he said. "She couldn’t say too much because she was afraid."

"She was telling me she was hiding under a table," Motolinia said. He said he heard more shots over the phone, and his sister hung up.

Caren Kesterson was working at a nearby Supercuts hair salon when two police cars sped past.

"We got up and we looked outside, and it was like almost immediately we heard gunshots — easily over 20,” Kesterson told MSNBC by telephone.

Colorado Gov. John Hickenlooper issued a statement to victims families shortly after the fatalities were announced: “Our deepest condolences go out to the families and loved ones of those who were killed, including UCCS Officer Garrett Swasey, and those who were injured," he said.

CSP will be doing a procession escorting fallen UCCS Officer Swasey 30-45 min. I-25 toCircle to Janitell to Las Vegas.@CSPDPIO — CSPD Communications (@CSPDComCenter) November 28, 2015

"Our thoughts continue to be with law enforcement, the Colorado Springs community, and the staff and patients at Planned Parenthood.”

A White House official said President Barack Obama had been notified about the situation, and he released a statement on Saturday calling for tighter gun control laws.

Democratic presidential candidate Hillary Clinton said in a tweet that "Today and every day, we #StandWithPP," referring to Planned Parenthood.

Vicki Cowart, president and CEO of Planned Parenthood Rocky Mountains, said Friday that "we don't yet know if Planned Parenthood was in fact the target of this attack."

But she vowed in a statement: "We will never back away from providing care in a safe, supportive environment that millions of people rely on and trust."

Cecile Richards, president and CEO of Planned Parenthood Federation of America, thanked law enforcement in a statement released Friday.

"Our hearts go out to the families and loved ones of the brave law enforcement officers who put themselves in harm's way in Colorado Springs," she said. "We are profoundly grateful for their heroism in helping to protect all women, men and young people as they access basic health care in this country.”