Prosecutors on Wednesday dropped charges against a Bronx cabbie who beat a man to death after investigators say the man tried to rape his wife.

Mamadou Diallo walked out of court Wednesday a free man.

Diallo, 61, had been facing assault, criminal possession of a weapon and harassment charges in connection with the May 30 attack.

The district attorney's office moved to dismiss all charges after consulting with the family of Earl Nash.

Back in June, Nash forced his way into Diallo's apartment.

Investigators say he beat Diallo's wife and tried to rape her before she called her husband for help.

Diallo called 911 and rushed back to the building.

He found Nash in an elevator and beat him with a tire iron.

Nash died from his injuries, as well as heart disease and cocaine in his system.

His family says he suffered from schizophrenia and never received mental health treatment.

Diallo and his wife Nenegale said they're relieved this ordeal is over.

"I was defending myself and my wife," Mamadou Diallo said. "I was emotional. I know I didn't do something wrong."

"I'm so happy because I said thank you for everybody for the community," Nenegale Diallo said.

"To me, he's a hero to me, because I live with him for a long time, I never see him fighting," said Ibraham Diallo, Mamadou Diallo's brother. "I never see him any problem."

Nash's family released a statement saying, in part, "As a family we pray that Mrs. Diallo and family may recover from the unfortunate trauma they’ve experienced. While we cannot undue (sic) 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."