The gunman who targeted New York City police officers in back-to-back shootings over the weekend, wounding two, has a history of violence that includes a prior gun battle against cops and an attempted murder conviction from nearly two decades ago, investigators said.

The suspect, who police believe carried out two “assassination attempts” on officers in the Bronx less than 12 hours apart, had been paroled in 2017 after an attempted murder conviction in 2002, Police Commissioner Dermot Shea said Sunday at a news conference.

Police identified him Sunday as Robert Williams, 45, of the Bronx.

BRONX ATTACKS ON NYPD LIKELY TO FURTHER INFLAME TENSIONS BETWEEN COPS, DE BLASIO'S CITY HALL

In 2002, the suspected gunman had shot a man and then carjacked a woman as he fled, Shea said. His bid to escape came to an end when he crashed the car and traded gunfire with New York City police officers.

Since his parole more than two years ago, he has one recorded arrest for which he was already scheduled to appear in court, the commissioner said.

The suspected gunman was quickly taken into custody inside the headquarters of the 41st Precinct in the Bronx on Sunday morning after unloading his 9mm handgun on officers, police said. Only after running out of bullets did the gunman lay down on the ground and surrender.

NYPD OFFICER SHOT, WOUNDED IN 'ASSASSINATION ATTEMPT'

“This is not a crime gone bad,” Shea said. “This is not a liquor store robbery interrupted that a tragedy erupts from. This is a premeditated assassination attempt.”

A police lieutenant was wounded in his upper left arm. He returned fire but did not hit the suspect. The lieutenant was expected to be released from the hospital later Sunday.

Investigators were confident the man in custody had carried out a similar assault Saturday evening on two uniformed police officers sitting in a patrol van, Shea said. One officer was wounded when a bullet grazed his chin and neck. Neither officer returned fire. The wounded officer was released from the hospital Sunday afternoon.

Police are conducting tests on the suspect's weapon that was recovered at the precinct to determine whether it was used in both targeted attacks, police said.

The twin attacks have spurred responses from police officials and President Trump who called on New York’s Democratic leaders, Gov. Andrew Cuomo and Mayor Bill de Blasio, to work with law enforcement to end the hatred and violence directed at cops.

POLICE OFFICERS KILLED IN LINE OF DUTY, 2020

"I grew up in New York City and, over many years, got to watch how GREAT NYC’s 'Finest' are," Trump tweeted. "Now, because of weak leadership at Governor & Mayor, stand away (water thrown at them) regulations, and lack of support, our wonderful NYC police are under assault. Stop this now!"

"It is a double miracle that we are not preparing for two funerals right now," New York City Police Benevolent Association President Patrick J. Lynch said in a statement.

Both Cuomo and de Blasio condemned the shootings. Cuomo said the attacks left him “horrified” and that the city has "zero tolerance" for any attacks on police. De Blasio told New Yorkers these were clear attempts “to assassinate” police officers.

"There is too much hatred out there, too much hatred in general and too much hatred directed at our officers,” de Blasio said at a news conference.

The attacks come amid rising tensions between the city’s 34,000-member force and the administration of de Blasio, who has implemented several measures that critics say are hostile to police.

CLICK HERE FOR THE FOX NEWS APP

De Blasio oversaw a continued dramatic decrease of the stop and frisk policy, which gave beat cops wide latitude to detain and search people for weapons, made the Big Apple a sanctuary city and has slated the Rikers Island jail for closure. In addition, new criminal justice reforms passed by state lawmakers effectively end cash bail for a wide variety of criminal suspects.

Fox News' Mike Arroyo and Greg Wilson contributed to this report.