The City Council voted 7-0 on a deal that ends a political stalemate after more than a dozen women publicly identified themselves as targets of unwanted advances, including touching, forcible kisses and lurid comments.
The 70-year-old Filner, a Democrat who served 20 years in Congress before becoming mayor of the nation's eighth-largest city, apologized to accusers but denied ever sexually harassing them.
He previously insisted he still could be an effective mayor and underwent two weeks of behavioral therapy before returning to work this week.
But his support diminished as more women - one of them a great-grandmother and another a retired Navy admiral - came forward and told stories of Filner touching, forcibly kissing, making lewd comments and even placing them in headlocks. Some of Filner's closest political allies and all nine members of the council called on him to quit.
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 City Attorney Jan 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 have 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.
"When my children ask me, 'Where were you when the public lynching of Mayor Filner took place?' I will tell them I was not an accessory," said Enrique Morones, president of immigrant advocacy group Border Angels.
Filner's biggest bargaining chip at the negotiating table was his refusal to resign.
A person with knowledge of the negotiations said the main sticking points during talks involved granting Filner indemnity and covering his legal fees in the sexual harassment lawsuit. The person was not authorized to comment publicly and spoke only on condition of anonymity.
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.
Allred said he City Council should not support it if in exchange for his resignation the city is going to use taxpayer money to pay Filner's legal bills.
"The mayor's resignation should not be bought at the expense of his victims," she said Thursday. "It would be morally wrong and hypocritical for the city to align itself with the mayor by helping him pay his legal fees."
McCormack, as she is known professionally, was the first woman to go public with allegations against Filner and her lawsuit is the only 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.
San Diego is not new to political scandals - Mayor Dick Murphy resigned in 2005 amid a financial crisis and Mayor Roger Hedgecock stepped down in 1985 after a felony conviction for conspiracy in connection with illegal campaign contributions - but even so Democratic consultant Chris Crotty said this has reached a new level.
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.
After taking office on Dec. 3, 2012, Filner struck a five-year labor agreement with city unions and opened a city of San Diego office in Tijuana to strengthen ties with the Mexican border city, However, he alienated many key players even before the allegations surfaced, including members of the City Council, the city attorney and hoteliers.
The liberal Democrat served 10 terms in Congress, marked perhaps most famously by a 2007 run-in with a United Airlines baggage handler at Dulles International Airport that resulted in him acknowledging a misdemeanor charge of trespassing. Joanne Kunkel alleged in a criminal complaint that Filner barged past other customers, screamed at employees, repeatedly pushed her and yelled, "You can't stop me."
Filner, who began his political career on the San Diego school board and later served on the City Council, is twice divorced. Bronwyn Ingram ended her marriage engagement days before the scandal broke and later said Filner sent sexually explicit text messages to other women and arranged dates in her presence.
Associated Press writers Elliot Spagat and Michael R. Blood contributed to this report. Blood reported from Los Angeles.