The courtroom erupted in cheers when the judge accepted the dismissal of charges against Mamadou Diallo.
Diallo, 61, returned to court for the first time since an autopsy ruled the death of Earl Nash, 43, the accused attacker, as a homicide.
Prosecutors read a statement from Nash's family agreeing to the charges being dropped. When Judge Marc Whiten approved the arrangement, the courtroom erupted in celebration from Diallo family members.
"This case was a tragedy for all whose lives intersected in that Bronx building on the night of May 30, 2016," said Bronx District Attorney Clark.
Watch video from inside the courtroom showing what happened next:
"We waited for three months for the autopsy results, and after a thorough investigation as well as discussions with the deceased's family we have determined that no grand jury action is warranted,' Clark said. "We are dismissing the charges against Mamadou Diallo."
According to the New York City Police Department, Nash illegally entered Diallo's building, approached the 51-year-old woman, beat her with a chair and hit her in the head, causing bruises to her forehead before removing her clothes.
The woman was able to break free and call Diallo, who was outside the building, on her cell phone. He rushed inside.
Diallo, police said, confronted the suspect in the sixth floor hallway and assaulted him with a tire iron. Nash was rushed in critical condition to Lincoln Hospital, where he later died.
Hours before the attack, Nash was spotted lurking in the hallway and elevator.
Diallo was charged with assault, but was released on his own recognizance in June.
On Aug. 26, the medical examiner ruled that Nash's death was caused by cardiorespiratory complications associated with blunt force trauma of the head, torso and upper extremities, acute cocaine intoxication and hypertensive and atherosclerotic cardiovascular disease.
Assistant District Attorney Jennifer Cruz read a statement from the Nash family in court that said in part, "We truly believe that both the Nash and the Diallo family have suffered a great deal of pain as a result of May 30, 2016....While we cannot undo the damage that was done that evening, we hope to bring some closure not only to our family but to the Diallo family as well. As such, we wholeheartedly recommend that District Attorney Clark dismiss all charges against Mamadou Diallo."