THORNTON, Colo. — A man suspected of fatally shooting three people inside a suburban Denver Walmart was arrested Thursday morning after an all-night manhunt, the police said.

The arrest of the suspect, identified as Scott Ostrem, 47, played out on live television. Officers staking out an apartment complex spotted him driving by in the same red Mitsubishi the police say he used to flee the scene of the shooting just hours earlier, according to an on-air description from a reporter for Fox 31 Denver. Officers raced after the car and arrested the suspect a few blocks away.

Victor Avila, a spokesman for the Thornton Police Department, said at a news conference Wednesday that investigators did not know of a motive, and said that the gunman did not speak before opening fire with a handgun just inside the store’s south entrance, near a group of cash registers. The police did not find the weapon.

Two men were pronounced dead at the scene, and a woman later died at a hospital, the police said. They did not release the names of the victims, and Mr. Avila said investigators did not know whether the victims knew one another, or just happened to be near one another when they were cut down by gunfire.

“‘This is a very heinous act,” Mr. Avila said. “It was certainly a terrible act.”

The report of gunshots first came in at 6:10 p.m. Wednseday, and dozens of police officers and emergency medical workers swarmed the parking lot of the Walmart, blockading roads and cutting off traffic around the suburban shopping plaza.

Hayne Rucker and Aaron Stephens said they had been checking out their purchases near the front of the Walmart when they heard a loud bang that echoed through the aisles. Two gunshots followed, and then three or four more in quick succession, they said.

“I just tore toward the door,” Mr. Rucker said.

Gonzalo Benitez, a construction worker, said he had been buying food for his family when he heard six or seven gunshots and customers began screaming.

“A lot of people crying, running fast,” Mr. Benitez, 44, said. “I see a couple of people on the floor.”

He and other customers rushed through the aisles to a rear exit door, he said, and had to pound against it to force it open.

Even as the Thornton police warned people to stay away from the crime scene, some frantic family members showed up to seek word about loved ones who had been working or shopping there when the shooting began.

The Walmart is part of the Thornton Town Center, a shopping complex steps from Interstate 25 in Thornton, a city of about 136,000 in the suburbs north of Denver. Outside the store, next to chain restaurants, apartment complexes and home supply stores, family members of shoppers and employees gathered across the street to wait for a sign of their loved ones.

“My brother is somewhere in there, and he doesn’t pick up,” said Maria Martinez, 19, as she walked around the flashing police cars blocking the entrance to the Walmart parking lot.

She said that her brother, Ignacio, 27, had gone to buy diapers for his three children, and that the family had been frantically texting and calling him since they heard about the shooting.

Mr. Rucker said the terrorist attack in Manhattan on Tuesday and other mass shootings in public places — like a music festival in Las Vegas, an Orlando nightclub and a movie theater in nearby Aurora, Colo. — had injected a sliver of fear into ordinary errands like running out to the Walmart for groceries.

“You can’t get that out of your mind,” he said. “When you’re in a public place and you hear gunshots, that’s kind of the first thing that comes to your mind: Here we go again. Looks like this time, we are potential targets.”