Nafissatou Diallo, center, who claims she was sexually assaulted by former International Monetary Fund leader Dominique Strauss-Kahn, exits a Bronx courthouse after the case was settled Monday in New York.

NEW YORK — The former French politician Dominique Strauss-Kahn and the hotel housekeeper who accused him of sexually assaulting her last year have agreed to settle her lawsuit stemming from their sexual encounter, a judge said on Monday.

The settlement, whose terms were not disclosed, was announced at a hearing in State Supreme Court in the Bronx, eight long miles from the headline-grabbing case’s genesis: a 28th-floor suite at the Sofitel hotel in Midtown Manhattan.

Justice Douglas E. McKeon entered the courtroom at 2:15 p.m., and said a deal had been finalized in his presence about 10 minutes earlier. Both sides agreed that the settlement would be confidential.

The housekeeper, Nafissatou Diallo, who was at the hearing and went public with her identity last year, said afterward: “I thank everyone all over the world and everyone at the court. God bless you all.”

Strauss-Kahn, who was not in court, was arrested in May 2011 after Diallo told detectives that he had sexually assaulted her in his suite. Strauss-Kahn was indicted on charges including attempted rape, sexual abuse, criminal sexual act, unlawful imprisonment and forcible touching.

The arrest threw Strauss-Kahn’s career in turmoil: He resigned his post as head of the International Monetary Fund in disgrace and his rumored candidacy for the French presidency was abandoned before it could begin. He was first held in jail without bail, and won his release to house arrest only under extraordinary conditions.

But the criminal case began to crumble when questions of Diallo’s credibility convinced the Manhattan district attorney’s office that it could not reasonably persuade a jury to trust her account. The case was dismissed in August 2011; court papers at the time described Diallo, an immigrant from Guinea, as having been “persistently, and at times inexplicably, untruthful in describing matters of both great and small significance.”

But by then, Diallo had filed her civil suit in the Bronx, where she lives.

Strauss-Kahn has said the sex with Diallo was consensual, though in a French television interview after the criminal case was dismissed, he acknowledged that the encounter was “an error” and “a moral failure” that he would forever regret.