ATLANTA — A gunman who opened fire at a medical office building in Midtown Atlanta on Wednesday, killing one and injuring four others, has been caught after a manhunt that lasted several hours, the authorities said.

The gunman, identified as Deion Patterson, 24, stole a vehicle after the shooting and later fled on foot, the Atlanta Police Department said. He left the surrounding area armed, the authorities said. Dozens of officers from several agencies took part in the sprawling search for Mr. Patterson, who was taken into custody in neighboring Cobb County about eight hours after the shooting.

“This was a horrible act of gun violence,” Mayor Andre Dickens of Atlanta said at a news conference on Wednesday night. “But equally horrifying is that we know that this is not unique in our country.”

Darin Schierbaum, Atlanta’s chief of police, said at an earlier news conference that officers responded to 1100 West Peachtree Street Northwest in Midtown Atlanta just after noon when the gunman fired shots with a handgun inside a waiting room on the 11th floor of a Northside Hospital medical office, killing a 39-year-old woman and injuring four others. All of the victims were women, Chief Schierbaum said.

The police have not detailed a possible motive for the shooting, which came as the country continues to reel from incessant acts of gun violence.

Mr. Patterson had been at the medical office building with his mother, the authorities said.

In a brief phone interview on Wednesday night before her brother was taken into custody, Whitney Code, Mr. Patterson’s sister, said that her brother was “not mentally stable” and hadn’t been so since he left the Coast Guard early this year.

The U.S. Coast Guard said in a statement that Mr. Patterson entered the military branch in July 2018, last served as an Electrician’s Mate Second Class and was discharged from active duty in January.

Ms. Code said that Mr. Patterson had recently been struggling to do basic things, like eating and getting out of bed, and that he had been at the medical building on Wednesday “to get help.”

She declined to answer questions about what may have prompted the shooting, saying, “I know as much as you know.”

“This is not like him,” Ms. Code said. “He was joyful, funny. But after he came home, he stopped talking to others, stopped eating, interacting with people.”

Ms. Code said that her brother needed to be “taken in — and alive.”

The authorities did not respond to questions about Mr. Patterson’s mental health at the news conference on Wednesday night.

Mr. Patterson had spent about two minutes inside the medical office building after the shooting before exiting on foot, the police said. He then stole a pickup truck that had been left running and unattended at a nearby gas station, the authorities said.

The authorities had been searching for Mr. Patterson in Atlanta as well as in neighboring Cobb County. The Cobb County Police Department said on Twitter that it was searching in the Vinings, Cumberland and Truist Park areas.

A Georgia Department of Transportation camera spotted Mr. Patterson at 12:30 p.m. in the Truist Park area, but the police did not learn of that detection until about 2:30 p.m., Sgt. Wayne Delk of the Cobb County Police Department said at an evening news conference.

The stolen vehicle was recovered in a nearby parking garage, Sergeant Delk said.

On Wednesday afternoon, the police cordoned off parts of the Atlanta Braves’ stadium, Truist Park, as officers swarmed the area and helicopters buzzed overhead.

Three of the surviving victims were in critical condition, Robert Jansen, the chief medical officer at Grady Memorial Hospital, said at a news conference. One of them was still in surgery as of late Wednesday afternoon, he said. Chief Schierbaum said the four injured women were 71, 56, 39 and 25.

Northside Hospital said on Twitter that it was cooperating with the authorities “following the shooting at our midtown #Atlanta location.”

The hospital added, “This tragedy is affecting all of us, and we ask for patience and prayers at this time.”

Midtown Atlanta, a dense urban district typically bustling with office workers and Georgia Tech students, fell to a hush Wednesday afternoon as word spread that a shooting had taken place and a gunman was at large. Several schools went into lockdown and held students past the usual dismissal time. Roads were blocked and the police warned people to stay away from the area.

By 3 p.m., sidewalks and streets were almost entirely vacant, save for police cars and heavily armed officers — and restaurant patrons or residents poking their heads out of windows and doorways to take in the scene.

The police shared initial images from security cameras inside the building that showed a man, whom they later identified as Mr. Patterson, wearing a mask, a gray hooded sweatshirt, dark pants and a cross-body bag.

Dr. Janson said that Grady Memorial Hospital, a trauma center, activated its mass casualty event protocol and initially anticipated 12 patients. They later stopped the protocol.

U.S. Senator Raphael Warnock, a Democrat, said on the Senate floor on Wednesday moments after the shooting that he was “in shock and sorrow and in grief for my home state.”

“If I am honest, I rise, really, with a deep sense of anger about what is happening in our country in the area of gun violence — and death,” Mr. Warnock said, urging senators to take action on gun control.

State Senator Josh McLaurin was eating lunch next door to Northside Medical at Pasta da Pulcinella when patrons began murmuring about the shooting. The restaurant’s management locked the door, and some diners rushed to the windows to peer outside, he said. The fascination concerned but did not surprise him, said Mr. McLaurin, a Democrat, given the proliferation of gun violence across the United States.

David and Robin Shipple were at the Northside Healthcare facility for a doctor’s appointment when staff members alerted them to the shooting. They sheltered in place for about 20 minutes before law enforcement officers barged in “with machine guns,” Mr. Shipple said.

“You always see it in the news,” he said, “but don’t think you’re going to get caught up in something like this.”

Sean Keenan reported from Atlanta, Remy Tumin and Eduardo Medina from New York and Johnny Diaz from Miami. Sheelagh McNeill contributed research.