A suspect with a long criminal history who shot a New York City police officer Tuesday night was awaiting sentencing on a prior gun bust, officials said Wednesday.  

Rameek Smith, 25, allegedly shot NYPD Officer Dennis Vargas in the Bronx as he was fleeing. The shooting occurred around 10:45 p.m. when two officers with the NYPD's public safety team were in an unmarked car and spotted Smith.

As he fled on foot, Smith turned around and opened fire, striking Vargas twice in the arm, police said. The officer returned fire and struck the suspect in the head. He later died. A 9-millimeter Glock handgun that was reported stolen last year in Richmond, Virginia was recovered from the scene.  

MANHUNT FOR BOYFRIEND OF NYPD CIVILIAN EMPLOYEE MURDERED IN QUEENS APARTMENT CONTINUES FOR THIRD DAY

NYPD officer shot

Officer Dennis Vargas was released from Lincoln Hospital just four hours after being shot in a New York City shootout. The suspect in the shooting was killed and has a long criminal history, authorities said. (@NYPDNews)

Vargas was taken to a hospital where he was released hours later. He is the eighth NYPD officer to be shot this year. Two officers were killed in January while responding to a domestic incident in Harlem. 

At the time of Tuesday's shooting, Smith was waiting to be sentenced after pleading guilty in December to possession of an illegal gun, NYPD Commissioner Keechant L. Sewell said. He had an extensive criminal history, she said. 

"We can't stand for these types of dangerous and highly avoidable confrontations with repeat offenders who are given every leeway by the criminal justice system," she said during a news briefing to discuss ghost guns. "We need to right these wrongs."

The guilty plea stemmed from an arrest in which Smith was caught jumping a subway turnstile in Coney Island, Brooklyn while carrying a handgun, officials said. He pleaded guilty to criminal possession and was awaiting sentencing in June. 

The bullets inside the weapon were deemed inoperable and he faced a lesser charge, officials said.

"Because the bullets were considered inoperable, the law says it was unloaded," Mayor Eric Adams said. "The bad guy didn't know it was inoperable. And because it was inoperable, it no longer carried with it, a higher crime."

At the time of the arrest, Smith was on probation for a 2016 robbery conviction. He was indicted for the new offense and released with no bail, Sewell said. 

Teresa Leto, a retired NYPD first-grade homicide detective, told Fox News that bail reform has contributed to the level of brazenness seen by criminals. 

"This is a real crack in our system," she said. "That this person after he commits another crime… his probation should have been violated at that time. If that happened, this officer wouldn't have been shot and this guy wouldn't have been dead."

Adams, a retired NYPD officer, said he has never seen the level of "total disregard" and "fearlessness" of armed criminals. 

Officer Dennis Vargas

Officer Dennis Vargas greets officers after being released from Lincoln hospital on Tuesday. (@NYPDNews)

CLICK HERE TO GET THE FOX NEWS APP

"I've never witnessed anything like this," he said. "There's real energy out there that it's alright to carry and use a gun because nothing is going to happen to you. That fear did not exist during the crack epidemic. Never before have we created the level of comfortability of carrying and using an illegal gun in our cities across America than right now."