The man suspected of executing a San Antonio police officer late Sunday morning staked out police headquarters just hours before the shooting and briefly gained access to a vestibule of the building before quickly leaving, officials said.

An extensive police dragnet had failed Monday to catch the unnamed suspect in the ambush killing of Detective Benjamin Marconi, 50, a 20-year veteran. Marconi was the first of four police officers in three states shot during a seemingly unconnected Sunday spree.

Three of the incidents appeared to be targeted attacks and involved law enforcement officers sitting unsuspectingly in their patrol cars, either waiting in traffic or after pulling vehicles over for traffic stops.

"I think the uniform was the target and the first person who happened along was the person he targeted," San Antonio Police Chief William McManus said on Monday of the Texas case.

A GLANCE AT POLICE AMBUSH KILLINGS IN THE US

Police in that investigation are searching for a 2009-2012 black Mitsubishi Galant with black rims that was believed to be driven by the suspected gunman.

Earlier Monday, San Antonio authorities released video surveillance footage showing the man outside police headquarters. He is seen speaking to a clerk on an intercom before being let in to a vestibule. But the man only stayed a short time before leaving. McManus wouldn't detail what the suspect said, only that he asked a question.

"I don’t know why he was in headquarters," McManus said. "We have some ideas why we believe he may have been in headquarters, but we're not sure."

Four hours later, the man is suspected of killing Marconi as Marconi sat in his patrol car across from police headquarters writing a traffic ticket at 11:45 a.m. local time.

While Marconi was in the squad car, a vehicle thought to be driven by the suspect pulled up behind him. A man got out and shot Marconi twice in the head. The final shot was fired as the assailant reached inside Marconi’s passenger window to shoot the father of two at close range.

McManus said dashcam footage of the incident existed, but he wouldn't say what was on the video.

Authorities had yet to identify a motive in the apparent ambush, which was only the first in a bloody day for police.

A St. Louis police sergeant was shot twice in the face at 7:30 p.m. Sunday night, but was expected to survive and was hospitalized in critical condition. The 46-year-old officer, who was not named, is a married father of three and, like Marconi, a 20-year veteran of the force.

“This officer was driving down the road and was ambushed by an individual who pointed a gun at him from inside of his car and shot out the police officer’s window,” Police Chief Sam Dotson said.

The gunman was later killed after he shot at other officers who returned fire. No officers were injured during that encounter.

An officer in Sanibel, Fla., was shot and injured during a similar incident when a person fired at the officer as he sat in his patrol car after finishing a traffic stop just before 8 p.m., The News-Press reported. Other officers fired back at the suspect, who was eventually taken into custody.

An officer in Gladstone, Mo., sustained non-life-threatening injuries during a struggle with a man in his late teens who had fled from a traffic stop, FOXC4KC reported. During the tussle, authorities said the man revealed a handgun, shots were fired and the teen was killed.

The shootings came less than five months after a gunman killed five officers in Dallas who were working a protest about the fatal police shootings of black men in Minnesota and Louisiana. It was the deadliest day for American law enforcement since Sept. 11, 2001.

Ten days after the Dallas attack, a man wearing a ski mask and armed with two rifles and a pistol killed three officers near a gas station and convenience store in Baton Rouge, La. And earlier this month, two Des Moines, Iowa-area police officers were fatally shot in separate ambush-style attacks while sitting in their patrol cars.

In 2016, 56 state, county and local officers have been shot while on duty.

The Associated Press contributed to this report.