SAN ANTONIO (Reuters) - A 31-year-old man was arrested on Monday in the fatal ambush shooting of a San Antonio police officer, one of four officers shot in the line of duty in Texas, Missouri and Florida a day earlier.

The attacks on Sunday, which injured three other officers and led to the shooting death of a suspect, revived memories of deadly ambushes targeting police in July in Dallas and Baton Rouge.

Otis McKane was arrested without incident in a car with woman and a 2-year-old, San Antonio police said, adding they did not know the motive for the killing of 50-year-old Benjamin Marconi, a 20-year veteran of the San Antonio force.

He was fatally shot as he sat in his squad car during a routine traffic stop outside the city’s police headquarters.

“Everyone is relieved,” San Antonio Police Chief William McManus told a news conference, adding the suspect has a criminal history.

“The fact that he has been taken into custody, that does not negate the fact that there are people out there who are still targeting police officers,” he added.

The assailant stopped his car behind the police cruiser, walked up and shot the officer in the head through the window as he was writing a ticket, McManus told a news conference earlier on Monday.

A man identified by the San Antonio Police Department as a suspect in the shooting death of police detective Benjamin Marconi, 50, is seen entering the police headquarters building in San Antonio, Texas, November 20, 2016, in a frame grab from video released by the police. San Antonio Police Department/Handout via REUTERS

The gunman then reached through the window, fired a second shot into the officer, returned to his vehicle and sped away.

A total of 57 U.S. law enforcement officers have been killed by gunfire so far this year, a 68 percent increase from the same period in 2015.

Also on Sunday, a 46-year-old St. Louis police sergeant was shot in the face by a person in a car who pulled up beside the officer’s cruiser at an intersection. St. Louis Police Chief Sam Dotson said the wounded officer was conscious and able to speak after the attack.

The suspect was later killed in a shootout after officers spotted his car, police said on Monday.

Meanwhile, a third police officer was shot on Sunday during a traffic stop on Sanibel Island on Florida’s Gulf Coast but was not seriously hurt, local media reported.

The officer was treated for a shoulder wound, according to the reports, while the suspect was apprehended at his home on an island off Fort Myers.

‘WORST NIGHTMARE’

In a fourth incident, a police officer in Kansas City, Missouri, was shot and, wounded during a struggle with an armed suspect who tried to flee after a traffic stop, police said.

The suspect was killed and a Kansas City police spokeswoman said investigators were determining whether the officer was shot accidentally by one his colleagues.

The Texas case is a capital murder, which can result in the death penalty, prosecutors said.

About four hours before the shooting in San Antonio, surveillance video showed the suspect had briefly entered police headquarters and asked a question of a desk clerk before leaving.

McManus said it was not immediately known why the suspect entered the building, and he declined to say what the clerk was asked.

“This is everyone’s worst nightmare,” McManus said. Referring to the recent ambush killings of police officers in Texas and Louisiana, he said, “Unfortunately, like Dallas, like Baton Rouge, it’s happened here now.”

The latest shootings come amid an intense national debate over the role of law enforcement and especially the use of force by officers against minorities.