As the nurse held his hand, he told people that he had been shot by a man in the parking lot between the Planned Parenthood clinic and the grocery store.

Image A booking photo released by the Colorado Springs Police Department shows Robert Lewis Dear, 57, the suspect in the shooting Friday at a Planned Parenthood clinic in Colorado Springs. Credit... El Paso County Sheriff's Office

“He was just so much in shock,” said Taylor White, 23, who was in the store. “He was like, ‘Some crazy person out there is shooting people.’ ”

The authorities identified the gunman as Robert L. Dear Jr., 57, a heavily bearded man with a rifle. The shooting killed three people — including Garrett Swasey, 44, a University of Colorado at Colorado Springs police officer — and wounded nine. After holding hundreds of people effectively hostage — at least 24 were evacuated from the Planned Parenthood clinic, and 300 were forced to shelter in place in the shopping areas nearby — Mr. Dear surrendered and was taken into custody at 4:52 p.m., the authorities said Saturday.

Two of the dead were civilians whose names were being withheld until Monday, when autopsies will be completed. Four of the wounded were civilians and five were law enforcement officers; all were taken to local hospitals to be treated for gunshot wounds.

People who were caught near the carnage on Friday described an excruciating, hourslong wait for the police to restore safety — or for the gunman to pierce their hide-outs. Those inside the clinic holed up in an ultrasound room and other hideaways. At one point, the police rammed a BearCat armored vehicle into the Planned Parenthood building and rescued some of the people inside.