The last Democratic presidential candidate to carry Fairfax County was Lyndon B. Johnson, when he defeated Republican Barry Goldwater in 1964. A county economic boom was underway, with families moving to ramblers in commuting distance of federal jobs.

Since then, Fairfax has followed the political path of many suburbs, shifting between Democrats and Republicans for local offices but staying reliably Republican for presidential candidates from Richard Nixon through President Bush. The trend mirrored Virginia's conservative leanings.

But on Tuesday, Washington's largest suburb went solidly blue, choosing Democrat John F. Kerry over Bush by 32,668 votes. The change of heart after 40 years was not enough to deny Bush a 9-point victory in the state. But by winning Virginia's largest voting bloc, Kerry confirmed a truth understood increasingly by both parties: As it takes on the character of a city -- where the foreign-born are now one-third of the population, where traffic is a constant headache and where new construction is going up more than out -- Fairfax is leaning Democratic, even outside the traditional dividing line of the Capital Beltway.

"The city is moving out to the suburbs," said Rep. Thomas M. Davis III, a Fairfax Republican who continues to buck the trend, handily winning reelection this week against a Democratic opponent. "We all recognized that Fairfax was going to turn. How big it would turn was unclear."

Sandwiched between Democratic Arlington, Alexandria and Falls Church to the east and north and Republican-leaning Loudoun and Prince William to the west and south, the county still swings both ways, choosing Bush over Al Gore, Gov. Mark R. Warner (D) over Mark L. Earley (R) and former governor James S. Gilmore III (R) over Donald S. Beyer Jr. (D). About half of the delegation to the General Assembly in Richmond are Democrats, representing districts in older neighborhoods inside the Beltway. Along with Davis, Frank R. Wolf, the county's other Republican congressman, was reelected Tuesday.

But the County Board of Supervisors has stayed in Democratic hands for a decade, and the party brushed off a GOP assault on spending and services last year with the election of Gerald E. Connolly over a well-funded challenger. The victory led the county's Republican Party to seek new leadership to repair what it acknowledged was a fractured and badly organized group.

Democratic leaders describe a moderate brand of politics in Fairfax that they say explains Kerry's victory.

"Fairfax is a highly educated community . . . that's moving toward centrist values," said Connolly, who ran as a pro-business candidate, winning the endorsement of the county Chamber of Commerce, a traditional GOP bastion. "We pay a lot of attention to national and international affairs. We cross party lines. President Bush's message did not fall on receptive ground."

Unlike its neighbors to the west, Fairfax has little room to grow. Instead, people moving from the District, the inner suburbs or from outside the region are displacing many families that are then migrating to outer suburbs where they can find more house for their money and more conservative values. Davis, for example, carried the inside-the-Beltway district of older homes where he started his career as the Mason District supervisor, "but not like I used to."

Since the county population crossed the 1 million mark two years ago, the realities of urban issues have crept in: gangs, a crowded jail, pedestrian accidents along busy highways. They are not the realities of a sleepy bedroom community. County leaders say the urban complexion tends to be more conducive to Democratic voting patterns.

Instead of new subdivisions of single-family homes, the county's growth now is centered in high-rises and townhouses in a handful of areas close to Metro stations. And the trend is drawing young professionals, the kind of new residents whose values tend to be Democratic, observers say.

This election also marked a political awakening among immigrants who are just starting to vote in Fairfax. Democratic Latino activists, for example, mounted major voter registration drives that they said paid off.

"We are pleased with what we saw," said Democrat Walter Tejada, Arlington's first Latino County Board member, who led get-out-the-vote efforts in his county, Alexandria and Fairfax.

The Democratic trend is making Republican county leaders nervous -- and determined to reverse it. "The county is changing, but I don't think the party has changed the way it approaches the county," said Eric Lundberg, elected as leader of the GOP last spring. He said the party needs to reach out to young voters and immigrants and plans to scour Tuesday's voting data for new voters to court.

Meanwhile, Kerry's showing in Fairfax is likely to keep the county in play in next year's race for governor, as Lt. Gov. Timothy M. Kaine, the likely Democratic nominee, and Attorney General Jerry W. Kilgore, the likely GOP candidate, rev up their campaigns. No governor in modern times has won Virginia without winning Fairfax.