The 8 a.m. incident took place in the 41st Precinct in the Longwood neighborhood of the Bronx, where the suspect walked in and began firing at the front desk, Police Commissioner Dermot Shea said at a news conference later in the day.
Police sources tell ABC News the suspect is Robert Williams and that he is also the suspect in the shooting of an officer in a police vehicle that took place Saturday night.
Williams, 45, has been charged with attempted murder, criminal possession of a weapon and resisting arrest.
"This was a premeditated effort to kill -- and not just to kill other human beings, but to kill those who wear a uniform that represents all of us," New York Mayor Bill de Blasio said at the news conference,
The suspect hit a lieutenant in the arm and the officer returned a shot but missed, Shea said.
The suspect then allegedly went into another room and fired at uniformed officers and a civilian worker, before he was stopped and apprehended by officers, according to Shea. The entire Sunday incident was captured on surveillance video, according to the mayor.
"This coward immediately laid down, but only after he ran out of bullets," the commissioner said.
The lieutenant, who has not been identified but is a 15-year veteran of the force, was rushed to Lincoln Hospital, and his injuries aren't life-threatening, according to police.
Shea said an investigation is ongoing, but the suspect has a violent criminal past. He said the suspect was arrested in 2002 and convicted for attempted murder in an incident where he shot at a person, carjacked a woman and then got into a shootout with police. The suspect was paroled in 2017, according to Shea.
On Saturday night, police say, the suspect walked up to officers who were in a marked police van and asked for directions before opening fire. The officer wounded in that attack yelled once he saw the gun and put the police car into drive but was struck by a bullet in the neck and chin during the commotion. Officers were not able to return fire during the incident.
The officer's partner then immediately drove the injured man to Lincoln Hospital. The officer has not yet been publicly identified, but authorities have confirmed he is an 8-year veteran assigned to the 41st Precinct and that he has known his partner since they were in middle school.
The officer hurt in the Saturday incident was released from the hospital Sunday to a crowd of cheering officers. Shea said he was grateful that none of the officers were killed during both incidents.
"It's only by the grace of God and the heroic actions of those inside the building that took [the suspect] into custody that we are not talking about police officers murdered inside a New York City Police precinct," Shea said.
The commissioner noted a rise in anti-police sentiment across the city, citing last week's subway protests against the NYPD and MTA and likened it to the protests that took place in 2014 before officers Wenjian Liu and Raphael Ramos were assassinated.
"Words matter. Words affect people's behavior," Shea said.
Mayor de Blasio echoed the commissioner's sentiments and called on New Yorkers to respect officers.
"Anyone who spews hatred at our officers is aiding and abetting this kind of atmosphere, it is not acceptable," he said. "You can protest for whatever you believe in but you cannot vilely attack those who are here to protect us."
Patrick Lynch, the president of the Police Benevolent Association, the union that represents cops, said in a statement he has been warning about this type attack for years and called on elected officials to "fix the deteriorating environment on our streets."
"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," he said.
President Donald Trump also weighed in on the shooting with a tweet.
"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!" he wrote.