A Louisiana man imprisoned for nearly four decades walked free Tuesday after his conviction in a 1979 rape was thrown out and prosecutors agreed to dismiss the charge.

Malcolm Alexander, 58, sat quietly and smiled broadly as friends and relatives applauded and cried after state District Judge June Darensburg ordered his release. Roughly two hours later, he walked out of the Jefferson Parish jail in the New Orleans suburb of Gretna.

Defense lawyers argued that Alexander's trial lawyer failed to point out that the victim had been doubtful when she identified Alexander as her attacker in 1979. Darensburg threw out the conviction based on the ineffective counsel argument.

DNA evidence — once thought lost but discovered in 2013 as Alexander continued to insist on his innocence — also played a role in the reversal, according to lawyers from the New York-based Innocence Project who handled the case. The evidence consisted of pubic hairs gathered from the crime scene, a bathroom in the victim's retail business. DNA testing showed the hairs matched each other but did not belong to the victim or Alexander, bolstering the argument that he was not the attacker, the attorneys said.

Innocence Project director Barry Scheck said cooperation from the Jefferson Parish Sheriff's Office and the Jefferson Parish District Attorney's Office was key to winning Alexander's freedom.

"I thank y'all from the bottom of my heart," his sobbing mother, Maudra Alexander, 82 and in a wheelchair, told a group of Innocence Project lawyers and others as court recessed.

"I've been praying my whole life for this," Alexander's son, Malcolm Stewart, said. He and other members were separated from Alexander — still-shackled and clad in prison orange — by a courtroom railing but were able to talk to him, and gather information such as shoe and clothing sizes ahead of his release.

District Attorney Paul Connick later released a statement saying he agreed that Alexander should be freed. "After an extensive investigation during the past 2 ½ years, I agreed with Mr. Alexander's post-conviction attorneys that the defense attorney during the daylong trial 37 years ago provided ineffective representation in violation of his constitutional rights," Connick said in a news release.