A gunman who opened fire inside a New York City police precinct Sunday morning, striking a police lieutenant in the arm, is believed to be the same suspect who had just hours earlier injured another police officer in his patrol car in a targeted assassination attempt, investigators said.

The second officer was shot just before 8 a.m. inside the headquarters of the 41st Precinct in the Bronx and was in stable condition at Lincoln Hospital, Police Commissioner Dermot Shea said at a news conference Sunday. A suspect was quickly taken into custody.

NYPD OFFICER SHOT, WOUNDED IN 'ASSASSINATION ATTEMPT'

The gunman walked into the precinct and immediately pulled out a 9mm handgun and fired several rounds toward the desk area where several uniformed officers were standing, Shea said. A lieutenant was struck in his upper left arm. He returned fire but did not strike the suspect.

The gunman then continued to fire multiple rounds "at point-blank range" into a room filled with officers and a civilian member of the department, but did not hit any in the room, Shea said.

Only after running out of bullets did the gunman lay down on the ground and surrender, police officials said, adding that the suspect has a lengthy and violent criminal history.

In 2002, the suspect, who has not been identified, was convicted of attempted murder after shooting a man in an incident that led to a subsequent carjacking and gunfight with police officers, officials said. He was paroled in 2017.

Police are conducting tests on the suspect's weapon to determine whether it was used in a targeted assault carried out less than 12 hours earlier against two police officers in an "ambush" on a patrol van in the same area.

In that incident, a man approached the uniformed officers' van just before 8:30 p.m. Saturday and asked for directions when he brandished a gun "without provocation," Shea said Saturday evening. Neither officer returned fire.

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

The officer at the wheel of the van was grazed in the chin and neck, but he avoided serious injury. The officer was released from the hospital Sunday to cheers from fellow officers.

President Trump condemned the shootings in a tweet early Sunday, blasting the "weak leadership" of New York's Democratic leaders, Gov. Andrew Cuomo and Mayor Bill de Blasio, before referencing a spate of incidents where patrolling officers were doused with water last summer.

"I grew up in New York City and, over many years, got to watch how GREAT NYC’s 'Finest' are," Trump wrote. "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!"

POLICE OFFICERS KILLED IN LINE OF DUTY, 2020

The Police Benevolent Association of New York called on elected officials to work with law enforcement "to fix the deteriorating environment on our streets" before tensions are further inflamed following the attacks.

"It is a double miracle that we are not preparing for two funerals right now," PBA President Patrick J. Lynch said in a statement. "These targeted attacks are exactly what we have warned against, again and again. The hatred and violence directed at cops continues to grow. Good luck and kind words are not enough to keep police officers or the public safe. Our elected officials need to start listening to us and working with us — not against us — to fix the deteriorating environment on our streets."

Gov. Cuomo also tweeted shortly after the shooting Sunday morning that he was “horrified” by the apparent back-to-back attacks on the city's law enforcement officers.

"Horrified by the multiple attacks on @NYPD officers in the Bronx," Cuomo wrote. "NY's law enforcement officers put their lives on the line every day to keep us safe. These attacks are heinous. Those responsible will be brought to justice & held accountable to the fullest extent of the law."

De Blasio praised the officers involved in the attacks, telling New Yorkers that an “attack on a police officer is an attack on all of us.”

"I want New Yorkers to be clear, this was an attempt to assassinate police officers," de Blasio said. "There is too much hatred out there, too much hatred in general and too much hatred directed at our officers."

Hours earlier, Shea had recalled other unprovoked assaults on police officers sitting in their patrol vehicles.

CLICK HERE FOR THE FOX NEWS APP

In 2017, a gunman killed Officer Miosotis Familia as she sat in her patrol vehicle in the Bronx. In 2014, two officers, Rafael Ramos and Wenjian Liu, were shot dead in their patrol car in Brooklyn by a man upset about recent police killings of unarmed black men. Shea said Ramos and Liu's deaths were “not something that engenders anything but the worst memories.”

Fox News' Tamara Gitt and The Associated Press contributed to this report.