Prosecutors on Wednesday dropped all charges against a Bronx man who beat to death another man who he said was attempting to rape his wife in their apartment building.

Mamadou Diallo, 61, was outside his apartment building on Washington Avenue and East 168th Street last May when he received a call from his wife, alerting him that she was attacked and nearly raped by a man inside.

Diallo confronted the man on the building’s sixth floor, where he clubbed him with a tire iron in an elevator, according to ABC7.

When authorities arrived, the man was sent to Lincoln Hospital in critical condition, where he later died.

Diallo was charged with assault in connection with the attack, but was released on his own recognizance, ABC7 reported.

The courtroom reportedly broke into cheers when it was announced that Diallo would not face charges in the man’s death.

"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,” a statement from the district attorney’s office read.

“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," the Nash family said in a statement. "As such, we wholeheartedly recommend that District Attorney Clark dismiss all charges against Mamadou Diallo."

“Really, really happy today, because it’s a surprise to me,” Diallo’s wife told 1010 WINS.