Los Angeles and San Francisco may be economic and cultural rivals, but politics in the state’s two most important cities are similarly harsh.

Both are dense mélanges of economic, cultural and ethnic “communities” that joust constantly and to those who aspire to high office, they are minefields laid atop pits of quicksand.

As fate would decree, both cities are suddenly in the throes of turmoil at or near the top of the local political pyramids.

WeeklyWalters: your Friday newsletter for all of Dan's columns.

San Francisco Mayor Ed Lee died of a heart attack in December and predictably, in a city where politics are a blood sport, politicians have been waging guerrilla war over his successor.

Meanwhile, 382 miles to the southeast, Los Angeles’ police chief and superintendent of schools announced their resignations this month, igniting sharp maneuvering over who will fill two high-profile positions affecting the daily lives of millions.

Because she happened to be president of San Francisco’s Board of Supervisors when Lee succumbed, London Breed became acting mayor, fully intending to run for the job later this year. That’s how U.S. Sen. Dianne Feinstein became mayor after the assassination of George Moscone in 1978.

However, the city’s most “progressive” factions – and other would-be mayors – didn’t want her to have the advantage of incumbency. Last week, therefore, the board’s left-wingers forged a deal with its moderates to bump Breed from the job she had held for scarcely a month and install Mark Farrell, a city supervisor and wealthy investment banker, as interim mayor instead.

Former Mayor Willie Brown, Breed’s most important supporter, cried foul, likening it to “a palace coup” in his weekly newspaper column – which is a bit ironic, since Brown has been the master of political ju-jitsu as mayor, as speaker of the state Assembly and as a behind-the-scenes kingmaker who handpicked both of his mayoral successors.

Only in San Francisco would Brown be seen as a crypto-conservative, but he and Breed are deemed by those to their left as too cozy with much-despised real estate interests.

Farrell’s win is an indirect boost for former state Sen. Mark Leno, a progressive favorite to become mayor, and the campaign leading up to the June election promises to be brutal.

Neither Los Angeles Police Chief Charlie Beck nor schools Superintendent Michelle King was elected, but both have been on the frontlines of the city’s very tumultuous evolution from white bread America to cultural polyglot.

There are no more fundamental issues for any community than how it is policed and how its children are educated and both Beck’s police department and King’s Los Angeles Unified School District have been buffeted by nonstop conflicts over the direction of their agencies.

As the Los Angeles Times put it, Beck – who came up through the ranks – “shepherded the department through crippling budget woes, a stubborn uptick in crime and a national outcry over police killings of black men.”

King, meanwhile, had been superintendent for just a year, chosen from among the huge district’s administrative ranks after a very fragmented school board could not agree on an outside candidate.

King was the ninth superintendent in 20 years, underscoring the difficulty of running a district with immense numbers of poor children and beset by serious financial problems and low academic performance.

The basic issue in both appointments is whether to once again tap insiders who would provide continuity or bring in someone new to shake up things. Both agencies have gone through such outsider-led shakeups in the past with decidedly uneven results