Criminal charges have been dropped against a Bronx cabby who beat his wife’s would-be rapist to death with a tire iron, prosecutors announced Wednesday.

Mamadou Diallo, 61, had faced assault and weapons charges after bludgeoning Earl Nash to death last May as the brute tried to rape Diallo’s wife inside their apartment.

Diallo’s family burst into cheers as Bronx Supreme Court Justice Marc Whiten signed off on the dismissal, while heroic husband sat stoically in court.

“There could be no joy in a circumstance such as this,” the judge said. “Mr. Diallo, you are free to go.”

Outside the courtroom, Diallo, who cried with his wife when he was informed of the dismissal Wednesday morning, seemed relieved.

“I’m happy for the American justice, and it’s the best way in the world, that’s what I say,” he said.

“These last three months — too hard for me. Some people tell me I am a killer. That’s hard for me,” he said, adding that he lost his TLC license and is out of work.

Nenegale said the dismissal was the right move.

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

The deal was brokered after consulting Nash’s family, prosecutors said in court.

“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,” the Nash family wrote in a statement that prosecutors read Wednesday.

“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.”

Diallo was searching for a parking spot outside his Claremont Village home when he received a frantic phone call from his wife, Nenegale, who had just been attacked by the career criminal.

The livery cab driver grabbed a tire iron and beat Nash, 43, as he confronted the pervert in the elevator of the building.

Nash later died at a hospital and his death was ruled a homicide in August, prosecutors said.

“We waited for three months for the autopsy results and after a thorough investigation as well as discussion with the deceased’s family, we have determined that no grand jury action is warranted,” said Bronx DA Darcel Clark in a statement.

Diallo, who is originally from Guinea, also expressed his condolences to the Nash family but insisted, “My religion doesn’t allow me to kill somebody. I don’t want to kill.”

Outside the courtroom, Diallo’s daughter Binta, 30, grinned ear to ear about the news.

“I feel great, I feel awesome. My dad is a free man,” she said.

She thanked the Nash family for supporting the dismissal of charges.

“We feel sorry for their son and we really appreciate it,” she added. “I’m hugging my dad the whole day. I’m so happy.”

Binta’s 16-year-old brother, Abdoul, was also elated.

“I am going home to celebrate. I’m going to eat a lot of goat and give my dad a hug,” he said.

Diallo’s lawyer Anthony Michaels called the entire ordeal a “nightmare” but said Wednesday’s resolution was “totally gratifying.”

“I think this is the right decision for everyone,” Michaels said. “I guarantee you he will never get in trouble again.”

Michaels also said that the DA’s Office plans to help the Diallo family find a new apartment because “this building has horrible memories for them” and they are “quiet people who want to put this behind them.”