Updated

Embattled San Diego Mayor Bob Filner has agreed to resign Aug. 30 after 17 allegations of  sexual harassment.

But in public remarks at a City Council meeting Friday announcing his resignation, an emotional Filner claimed he was the victim of a “lynch mob” and “if given due process, I would be vindicated.”

The City Council voted 7-0 to accept a deal with Filner to end a political stalemate after 17 women, including a great-grandmother, identified themselves as targets of unwanted advances, including touching, forcible kisses and lurid comments.

Filner, 70, who has been in office just nine months, began his remarks by saying “I offer a deep apology. The city should not have been put through this. My own personal failures are responsible and I apologize to the city.”

Referring to the harassment allegations, he said, "To all the women that I've offended, I had no intention to be offensive, to violate any physical or emotional space.

"I was trying to establish personal relationships but the combination of awkwardness and hubris led to behavior that I think many found offensive."

But he quickly became defiant, saying he had fallen victim to the “hysteria of a lynch mob” which he called an “affront to democracy.”

Filner said his resignation was “obviously the toughest decision of my life” and he vowed “I will not give up.”

Under the agreement negotiated between Filner and the City Council, the city will pay Filner's legal fees in a joint defense of a lawsuit filed by the mayor's former communications director and pay for any settlement costs assessed against the mayor except for punitive damages, said City Attorney Jan Goldsmith. The city would also pay up to $98,000 if Filner wants to hire his own attorney.

Goldsmith said the city was obligated to provide his legal defense no matter what.

Filner, a Democrat who served 20 years in Congress before becoming mayor of the nation's eighth-largest city had previously insisted he still could be an effective mayor and underwent two weeks of behavioral therapy before returning to work this week.

On Friday, just before the Council vote, the Democratic National Committee took the extraordinary step of passing a resolution demanding Filner leave.

Dozens of people spoke for and against the mayor before the council convened behind closed doors to discuss confidential terms negotiated by Filner and Goldsmith.

"Without the mayor's resignation, our city will continue to be paralyzed by this scandal, progress will be arrested and our focus will continue to be monopolized by this dark chapter in our history," said Laura Fink, a political consultant who accused Filner of patting her buttocks in 2005 when she was deputy campaign manager to the then-congressman.

Rachel Laing, a spokeswoman for an effort to recall the mayor, said petition gatherers had collected 20,000 signatures in five days to qualify for the ballot but that she would accept a deal for the mayor to resign.

"Every day he's in office is a day that the city remains in paralysis and that his victims suffer," she told the council.

Still, many who came to the special meeting supported the embattled mayor, hailing the liberal Democrat's work on behalf of civil rights and struggling minority groups.

Filner's biggest bargaining chip at the negotiating table was his refusal to resign.

The deal was negotiated between Filner, his lawyers, Goldsmith and two City Council members. It does not include attorney Gloria Allred, who represents Filner's former communications director, Irene McCormack Jackson, in a lawsuit filed against Filner and the city.

McCormack, as she is known professionally, was the first woman to go public with allegations against Filner and her lawsuit is the only one filed against the mayor and the city. McCormack claimed the mayor asked her to work without panties, demanded kisses, told her he wanted to see her naked and dragged her in a headlock while whispering in her ear.

Filner's troubles may also not be over. The San Diego County Sheriff's Department has interviewed the mayor's former communications director and opened a hotline to field any complaints about Filner. Investigators will deliver their findings to California attorney general's office to consider any possible criminal prosecution.

Todd Gloria, the Democratic City Council president, becomes acting mayor until a special election is held within 90 days. Democrats enjoy a solid edge over Republicans in voter registration, but the GOP will capitalize on the Filner debacle to try to reclaim an office it has held for nearly all of the last four decades.

Filner, who began his political career on the San Diego school board and later served on the City Council, is twice divorced.

The Associated Press contributed to this report