SAN DIEGO — Bob Filner, the former San Diego mayor forced out of office in a storm of sexual harassment allegations, pleaded guilty on Tuesday to a series of false imprisonment and battery charges involving three women.

The episode for Mr. Filner and the city he led for less than a year ended at a swift 16-minute court hearing in Superior Court, where Mr. Filner, dressed in a crisp blue suit and a gold tie, entered his plea with a series of “yes, sirs” as the judge described the scope of the one felony charge and two misdemeanor charges.

It was a sharp contrast from his resignation speech in August, when the mayor said he had been the victim of a “lynch mob.” His lawyer, Jerry Coughlan, said afterward that the once-defiant Mr. Filner, who faced sexual harassment allegations from 17 women, had “learned to get beyond denial” during his treatment for sexual disorders at a facility in Los Angeles in September.

Under the terms of the plea agreement with the state attorney general, Kamala Harris, Mr. Filner will be on probation for three years. As a condition of probation, Mr. Filner will submit to treatment at the discretion of a mental health professional.

Mr. Filner, 71, also faces three months of house confinement and a loss of his pension from the time of the first allegation to the date of his resignation, a period of about six months. Mr. Filner will face a six-month jail term if he violates the terms of his probation.

The deal signals the end of Mr. Filner’s life in elective politics, which included nearly 20 years in Congress and the distinction of being the first Democrat elected mayor here in more than 20 years. He is barred from ever again running for office.

The plea bargain was announced by Ms. Harris, who stepped in to prosecute the case after the district attorney in San Diego County, Bonnie Dumanis, recused herself; Ms. Dumanis, a Republican, had run and lost against Mr. Filner in the mayoral race.

“This conduct was not only criminal, it was also an extreme abuse of power,” Ms. Harris said. “This prosecution is about consequence and accountability. No one is above the law.”

Video

Eighteen women have accused Mayor Bob Filner of San Diego of sexual harassment, prompting calls for his resignation and a recall petition.CreditCreditFred Greaves/Reuters

Mr. Filner could have been sentenced to three years in prison and fined $10,000 for the felony count, and 12 months and $4,000 for each of the misdemeanor counts.

Mr. Filner, who looked thinner and tanner since his last public appearance — his lawyer said this was a result of regular jogs in the Southern California sun — did not offer an apology or explanation for his actions during the court session. Mr. Coughlan said that Mr. Filner felt remorse for his actions.

“Mr. Filner profusely apologizes to each person he might have harmed,” Mr. Coughlan told reporters after the hearing. “This permits the various women to put this behind them, too.”

“This was Mr. Filner’s chance to put all of this behind him,” he said. “His conduct, he has admitted, was inappropriate and over the top.”

The California attorney general’s office said that Mr. Filner, who resigned in August with a defiant speech, had been charged with one felony count of false imprisonment by violence, fraud, menace and deceit, and two misdemeanor counts of battery.

The felony took place at a fund-raising event on March 6, when, according to the complaint, he restrained a woman identified as Jane Doe 1 against her will, apparently using the “Filner headlock,” which became a legacy of this episode.

The first misdemeanor took place on April 6 at a “Meet the Mayor” event. There, the complaint said, Mr. Filner met Jane Doe 2,” who was there to discuss an issue, and Mr. Filner kissed her on the lips against her will.

“Is that true?” asked Robert J. Trentacosta, the presiding judge of Superior Court in San Diego.

“Yes, sir,” Mr. Filner responded, his hands folded in front of him as he stood before the court.

The second misdemeanor took place on May 26 at a rally on Fiesta Island. Jane Doe 3 approached the mayor and asked for a photograph and, according to the complaint, Mr. Filner touched her buttock.

“Sir, is that true?” Judge Trentacosta asked.

“Yes, sir,” the former mayor said.

Mr. Filner represented San Diego in Congress for 20 years. He was elected mayor last November with 52 percent of the vote. Todd Gloria, the Democratic City Council president, has been serving as acting mayor since Mr. Filner’s departure, pending a special election to replace him.

Correction:Oct. 15, 2013

An earlier version of this article misstated the sentence Bob Filner could have served. It was three years in prison for the felony and one year in county jail for each of the misdemeanors, not just three years in prison.

Rob Davis reported from San Diego, and Adam Nagourney from Los Angeles.

A version of this article appears in print on , on Page A19 of the New York edition with the headline: Ex-Mayor of San Diego Pleads Guilty to Charges of Sexual Harassment. Order Reprints | Today’s Paper | Subscribe