The NYPD detective attacked Thursday by a meat cleaver-wielding homeless man was released from the hospital on Friday afternoon.

Off-duty Det. Brian O’Donnell sustained a 6-inch cut from his temple to his jaw when he tried to subdue suspect Akram Joudeh, 32, in midtown Manhattan, authorites said.

Chief of Department James O'Neill said that officers responded to West 31st Street and Broadway just before 5 p.m., where Joudeh was trying to remove a boot from the white sedan he lives in. Joudeh pulled the cleaver from his waistband and fled to Sixth Avenue and then west on 32nd Street toward Seventh Avenue, O'Neill said.

​Three officers fired 18 shots at Joudeh outside of 116 W. 32nd St., striking him several times, after he mounted the grill of a cop car and then slashed the detective who attempted to subdue him, O'Neill said. Joudeh was taken to Bellevue Hospital Center in critical but stable condition, O'Neill said. He remained at the hospital Friday morning, police said.

O'Donnell, a 16-year NYPD veteran assigned to the 19th Precinct, was released from the hospital around 1:10 p.m. on Friday. He was seen on video surrounded by family and fellow officers as he was released from Bellevue Hospital Center.

Two other police officers suffered minor injuries and were taken to Bellevue; at least one was being treated for a possible graze wound, a police source said. Both officers were released from the hospital, police said Friday.

Outgoing Police Commissioner Bill Bratton said he visited all three officers in the hospital before they were released and said that the injured detective was in "good spirits, but he has a very significant injury to his head caused by the wielding of that meat cleaver." Mayor Bill de Blasio also went to Bellevue Hospital to check on the wounded officers.

Joudeh was in critical condition and being moved into the operating room when Bratton was at the hospital, Bratton said.

O'Neill said that police had used a Taser, striking the suspect with no effect, during their encounter with Joudeh before he attacked the detective. Police said they plan to investigate why the Taser was not effective.

O'Neill said Joudeh had a number of prior arrests, but wouldn't comment further.

Bratton said that police have "significant video" of the incident and commended cops "for their performance."

"They had a character running down the street, waving a cleaver. Despite that, the officers approached him, sought to take him in custody, at which time one of them received a very significant injury to his face, at which time, based on the preliminary investigation, the officers fired sufficient rounds to stop the attacks on the officers," Bratton said.

"I want to commend them for their bravery and performance of duty," he continued. "Sufficient shots were fired to deter the attack on my officers by the suspect." 

Franchesca Benitez, 26, the manager of Mandee Boutique in the Manhattan Mall on the corner of Sixth Avenue and 32nd Street, said employees were getting ready to change shifts when she heard shots.

Initially, she said, she thought it was a car crash or even a terrorist attack. She ran to the other Mandee store that's farther back in the mall, where she found employees trying to hide in dressing rooms. 

"It was crazy, it was insane," she said. "I didn't know what to think, just commotion."

Rockville Centre lawyer Joseph Sands was in his office nearby when he heard gunfire.

"I heard gunshots from my office, pow, pow, pow, pow," he said. "Then all of a sudden I heard sirens."

"It sounds terrible," he added. "I'm surprised to hear it anywhere. I just know it from movies." 

Witness Cory Melton said he was at the corner of 32nd Street and Seventh Avenue checking his phone when he heard shots ring out. He said he saw a guy on the ground and cops were "working on him."

Pierre Damico, 62, from New Hyde Park, was shopping on 32nd Street when he heard the commotion.

"My heart is still going," he said. "Everybody just took off. It's scary."