SAN DIEGO — When Bob Filner resigned as mayor last summer amid a sexual harassment scandal, Democrats openly fretted over losing the first liberal in decades elected to run this city, long a Republican bastion on the southern edge of the state.

Now as voters prepare to elect Mr. Filner’s successor on Tuesday, the city is engaged in a fierce ideological battle: Will it elect David Alvarez, a Democrat and first-term city councilor who is championing a minimum-wage increase, or Kevin Faulconer, a Republican councilor who argues that the city must keep pensions down and attract new businesses?

The mayor’s race in San Diego, the nation’s eighth-largest city, is in many ways a fight for its political soul. For years, residents here have picked moderate Republicans who have the backing of city developers, transforming downtown into a model of urban redevelopment with bustling, pedestrian-friendly streets that have become prime tourist attractions. But many Democrats argue that the powerful, business-focused elite have neglected and ignored working-class neighborhoods outside the city’s center, creating a sprawling urban area divided sharply by class.

With Mr. Faulconer receiving support from most of the city’s business leaders and Mr. Alvarez taking in millions from labor unions, the election’s outcome will signal how eager voters are to continue the break from the past that they once expected Mr. Filner to provide. And with unaffiliated voters the fastest-growing segment of the electorate, it is also a test of whether yet another big-city Democrat can be elected by riding a wave of populism, much as Mayor Bill de Blasio of New York did last fall.