The charges against Mamadou Diallo, the Bronx man who was charged with fatally attacking his wife’s would-be rapist at their home in May, were dropped Wednesday as prosecutors read a letter requesting as such from the family of the man he killed.

“There can be no joy in a circumstance such as this,” Justice Marc Whiten said.

“Mr. Diallo, you’re free to go,” Whiten added, amid loud clapping in the courtroom.

Diallo’s family, including his wife and three sons, appeared overwhelmed by the unexpected outcome. His appearance at Bronx Supreme Court was originally scheduled to be a routine hearing to discuss a possible plea deal.

“I was emotional. I was defending myself and my wife,” Diallo, 61, said outside the courtroom, adding that “justice in America is the best.”

On May 30, Diallo received a phone call from his wife who said a man had forced his way inside their Washington Avenue home and tried to sexually assault her, police said. Diallo, who was working nearby as a livery cab driver, rushed home and intercepted Earl Nash in the hallway of their building. Diallo then hit Nash with a tire iron as he tried to escape, according to police.

An autopsy found that Nash, 43, who suffered from schizophrenia, according to family, died of cardiorespiratory complications associated with his injuries, acute cocaine intoxication and heart disease.

But in June, Diallo’s charges were reduced from manslaughter to assault and he was released without bail.

Assistant District Attorney Jennifer Cruz said the prosecutor’s office analyzed the law and the medical examiner’s report as well as the Nash family’s wishes in their decision to dismiss the case.

“To know that Earl was part of this tragedy is truly devastating to us all,” Nash’s family said in a statement. “We pray that Mrs. Diallo and family may recover from the unfortunate trauma they’ve experienced.”

His family said Nash, the oldest of five children who once excelled in sports, acted in television and music videos, and attended Howard University in Washington, D.C. But Nash “suffered a mental breakdown” and was diagnosed with schizophrenia after his mother’s death in 1995. He then began to self-medicate, they said, and never received the mental health treatment he needed.

“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,” they added.

As she left the courthouse, Diallo’s wife, Nenegale Diallo, put her hand to her mouth, relieved the ordeal was finally over. She was surprised the charges were dismissed.

“I’m feeling good,” she said. “I think they did the right thing because he was defending me. That’s what a husband does.”

Mamadou Diallo, who his attorney said was worried about taking a plea deal because of potentially being deported to his native Guinea, said he never had any intentions to harm anyone.

Now, he plans to rest a bit before seeking to reobtain his TLC license so that he can go back to driving a livery cab.

His son Abdoul Diallo, 16, said he was going home to celebrate with his family.

“I’m going to eat a lot of goat and give him a hug,” he said.

“This case has always been a hot potato,” Diallo’s attorney, Anthony Michaels, said, adding that the letter from Nash’s family certainly helped. “We are grateful for their intelligence in analyzing the situation, their compassion expressed in the letter.”