Dominique Strauss-Kahn, one of France's leading politicians, walked free from a New York courtroom after a judge dropped charges against him for allegedly sexually assaulting a hotel maid.

The move brings to an end a dramatic legal tussle that has gripped both sides of the Atlantic and could resurrect the former French presidential hopeful's seemingly dead political career in France.

Prosecutors for Manhattan's district attorney Cyrus Vance told justice Michael Obus of State Supreme Court in Manhattan that they could not prove the case beyond a reasonable doubt because of serious credibility issues with Nafissatou Diallo, the hotel housekeeper who had accused Strauss-Kahn, the former chief of the International Monetary Fund, of sexually assaulting her.

In court Joan Illuzzi-Orbon, the assistant district attorney, called Diallo's testimony "surreal" and said she lied to prosecutors on numerous occasions, even denying she had made statements previously witnessed by several law officials.

Obus told the packed court he would comply with a request from the prosecution to throw out the case: "The indictment is dismissed."

There was initially some confusion after lawyers for Diallo appealed against the judge's decision not to appoint a special prosecutor. That appeal was quickly dismissed.

After the judgment Strauss-Kahn's lawyers praised the decision but attacked the fact that the case had gone so far. Benjamin Brafman said: "This was not a forcible encounter … This case was treated as a crime when it was not."

Brafman also spoke of the toll the process had taken on the accused. He called it a "horrific nightmare" and said Strauss-Kahn and his family had handled the ordeal with "class".

Another defence lawyer, William Taylor, attacked Strauss-Kahn's treatment by the US justice system and the media. "What a tragedy in the life of Dominique Strauss-Kahn. This is not about wealth nor power nor race … There was a collective rush to judgment by not only law enforcement but also by the media," said Taylor.

Such sentiments cut little ice with the large groups of protesters gathered outside court. Many were against Strauss-Kahn, waving placards and chanting slogans such as "DSK! Shame on you!"

As Strauss-Kahn left the building, one woman screamed at him: "You dirty bastard! You dirty bastard!"

Outside court Ken Thompson, Diallo's lawyer, attacked the ruling. "No man, no matter how much power, money and influence he has, has a right to sexually assault a woman," Thompson said. "We are disappointed that District Attorney Vance apparently does not believe in equal justice under the law and has denied an innocent woman a day in court."

Michael Greys, co-founder of the group 100 Blacks in Law Enforcement, was furious at the dismissal. "American justice is not blind," he said. "Race and class still play a part. This was a case of a millionaire against a poor black woman with no education." Rudy Dent, another Diallo supporter said the decision was down to "plantation politics."

Strauss-Kahn, 62, was arrested in May after Diallo, 32, said he had forced her to perform oral sex when she arrived to clean his suite at the Sofitel hotel in Manhattan. The French Socialist party veteran was arrested on a plane scheduled to fly to Paris.

Strauss-Kahn has never contested the fact that a sexual encounter took place but has denied claims it was forced. He should soon be free to return to France, where the authorities are investigating claims that he tried to rape a French journalist, Tristane Banon, in 2003. His lawyers have dismissed her accusations as "fantasy".

Her lawyer David Koubbi, who travelled to New York to see prosecutor Cyrus Vance and meet Diallo, said he was dismayed by the decision to drop the sexual assault charges against Strauss-Kahn.

"I regret this outcome. I regret it for Nafissatou Diallo because I believed what she said," he said. "I spoke to Tristane on Monday evening by telephone then during the night, then this morning [Tuesday].

"She is in a fighting mood. She isn't ready to let this drop. But she feels sorry for what has happened to Nafissatou Diallo because she also believed her."

He added: "The credibility of my client is not, and has never been, called into question because of this."

The office of the Manhattan district attorney initially called Diallo's statement "compelling", stressing that she had provided "very powerful details". Her story was buttressed by forensic evidence: his semen was found on her uniform and her lawyer said doctors had taken photographs of her bruised vagina.

But the case started unravelling after prosecutors said Diallo had lied to them and other US officials about her past, including giving a false account of having been gang-raped in her native Guinea. Diallo told interviewers she had used the false story to get herself and her daughter a chance of a better life in the US.

There were also discrepancies in what happened after the alleged attack. She told a grand jury she had stayed in the hallway outside Strauss-Kahn's room after the attack when evidence showed she had actually returned to his room, and to another one, before consulting her boss.

It then emerged she had discussed Strauss-Kahn's wealth in a recorded phone conversation after the supposed attack.

In her defence, Diallo's lawyers said prosecutors were misinterpreting the conversation, conducted in Fulani, her native language, and that her account of the assault during the call had not differed.

A court document filed on Monday by prosecutors contained a devastating and detailed account of how Diallo had misled investigators.

"In virtually every substantive interview with prosecutors, despite entreaties to simply be truthful, she has not been truthful on matters great and small," the document said, adding that the cumulative effect of Diallo's misleading statements would prove "devastating" at any jury trial on the case.

"If we do not believe her beyond a reasonable doubt, we cannot ask a jury to do so," the document said.

The battle between Diallo and Strauss-Kahn was not fought entirely in the courts, with media coverage probably causing lasting damage to his career.

As Vance's team appeared to turn against her, Diallo went public. She gave up her anonymity to air her side of the story in Newsweek and on ABC. Diallo repeated the details of the attack and said that while she had made some mistakes, these should not dissuade prosecutors from fighting her case.

She then sued Strauss-Kahn on 8 Augustin civil court, a move that legal experts said made Vance's position even more difficult: the Frenchman's lawyers claimed the suit proved she was out for money.

However, the civil case is continuing, is unaffected legally by the dropping of criminal charges, and has a lesser burden of proof. Diallo's lawyers will have to prove merely that it was "more likely than not" that Strauss-Kahn committed an assault.

Ron Kuby, a criminal defence and civil rights lawyer, said Vance and Diallo had badly mishandled the criminal case. "From the beginning Cyrus Vance did everything wrong that it was possible to do wrong, and for the worst possible reasons," he said. "It was a tragedy of error and hubris."

However, the embattled DA has the support of his respected predecessor, Robert Morgenthau, who has defended his actions and decisions in the case. "The most important attribute I looked for in hiring junior prosecutors was a strong ethical sense. The recent actions from the district attorney's office show me that these attributes are alive and well," he said.