RICHMOND, Calif. — The Chevron refinery’s massive oil storage tanks sit on the hills overlooking this small, impoverished city in San Francisco’s East Bay. Painted earthen red to blend with the natural surroundings, the tanks cannot help dominating the city’s skyline, much the way the oil giant itself has long shaped Richmond’s identity, economy and politics.

But Chevron’s grip on Richmond’s politics began to loosen a few years ago after left-wing anticorporate activists seized control of the City Council and mayor’s office. In an area of the country where high-tech companies tend to coexist peacefully with affluent municipalities, perhaps nowhere have locals and a giant corporation rubbed shoulders with such intensity as in Richmond.

If city leaders likened themselves to anti-oil-company fighters in Nigeria, Ecuador and other developing oil-rich nations, Chevron’s response would not have been out of place in the Niger Delta. It has spent millions of dollars on social programs and community-building here, as well as on friendly politicians.