Virginians elected Democrat Timothy M. Kaine yesterday as the state's next governor, choosing him to continue the centrist legacy of popular Gov. Mark R. Warner (D) and rejecting the Republican candidate for the state's top job a second time in four years.

Kaine, 47, emerged ahead of his Republican rival, former attorney general Jerry W. Kilgore, 44, who had worked for months to convince voters that Kaine was too liberal for the conservative state. Sen. H. Russell Potts Jr. (R-Winchester), who ran as an independent, trailed far behind the major-party candidates.

"This has been a long and difficult campaign. . . . We've done it. We've done it," Kaine told a roaring crowd in Richmond just after 11 p.m. "Tonight, the people of Virginia have sent a message . . . that they like the path that we chose and they want to keep the state moving forward."

Kilgore spoke to his supporters in Richmond just after 10:30 p.m. "We fought hard," he said. "We fought diligently for limited government" and for schools. "And folks, that fight is not over. Tonight we may have lost a battle. But we have not lost, and will not lose, this war."

Kaine's party also succeeded in several contests for the House of Delegates in Northern Virginia. Democrats bested Republicans for several open seats. Democrat David E. Poisson defeated Del. Richard H. "Dick" Black (R-Loudoun), and Del. Jeffrey M. Frederick (R-Prince William) won a close race against Democrat Hilda M. Barg.

Democrats' easy successes did not extend to the other statewide races. Republican state Sen. William T. "Bill" Bolling of Hanover County won the lieutenant governor's race against Democrat Leslie L. Byrne of Fairfax County, the only statewide candidate from populous Northern Virginia. Republican Del. Robert F. "Bob" McDonnell of Virginia Beach and Democrat R. Creigh Deeds of Bath County remained in a tight race for attorney general.

Kaine watched as results came across a laptop computer in Suite 1706 of the Richmond Marriott. With him were three generations of governors: his father-in-law, A. Linwood Holton Jr., Warner and L. Douglas Wilder, the nation's first elected black governor. As Kaine was declared the winner, Holton had tears in his eyes, a Warner aide said.

Kilgore called at 10 p.m. to concede, Kaine aides said.

Kaine, the former mayor of Richmond, won handily across the inner suburbs of Northern Virginia and in Fairfax County, where the Democratic Party has been gaining strength in recent years. But he also posted big numbers in the conservative strongholds of the region's outer suburbs.

Kaine won in Loudoun and Prince William counties, where President Bush beat Democrat John F. Kerry by tens of thousands of votes a year ago.

Political observers said the results confirmed a steady westward expansion of such urban concerns as traffic and education.

"This is a huge shift of historic proportions for Fairfax County," said Fairfax County Board of Supervisors Chairman Gerald E. Connolly (D). "You have to play in a moderate, centrist battlefield. Kilgore clearly went on a route too far afield, and he paid the price. . . . You are starting to see the march of moderate politics go out to the outer suburbs."

By the time Kaine leaves office in 2009, the Democrats will have controlled the governor's mansion for all but eight of the past 28 years. "We've always had this perception that we are a reliable Republican state on presidential elections," said Republican consultant Chris LaCivita, a former chairman of the Virginia GOP. "We are not a reliable Republican state in governor's elections."

Kilgore, who consistently led in polls early this year, struggled across the state on Election Day. He was leading in some rural areas, including his birthplace of southwest Virginia and in the Shenandoah Valley. But Kaine bested him in the growing suburbs around Richmond, where Kilgore now lives.

From the beginning, Kaine's strategy was to target voters who like Warner. He repeatedly took credit for the accomplishments of the "Warner-Kaine administration," and he appeared frequently with the governor.

Kaine also broke with traditional Democratic tactics and talked regularly about his Catholic faith. His standard stump speech mentioned his work as a missionary, and several of his radio and television ads highlighted his Catholicism.

"The Bible teaches we can accomplish great things when we work together," Kaine said in an early radio ad.

Kaine promised tougher evaluations for teachers, universal preschool for 4-year-olds and better coordination of land use and transportation planning. He also proposed exempting the first 20 percent of a home's value from the property tax.

In the waning days of the campaign, Kaine cast his lot with the slow-growth movement in Virginia's outer suburbs. In a television ad, he promised to give local governments the ability to say "No" to development if the nearby roads are not sufficient.

Kilgore's strategy was always to depict Kaine as a liberal who is out of step with mainstream Virginia values. To win, his advisers decided early, Kilgore had to make voters believe that Kaine was not a Warner clone.

His ads drove home that point. He accused Kaine of wanting to raise taxes and attacked Kaine's record as mayor of Richmond.

The climax to Kilgore's attacks came in early October, when he released two highly charged death penalty ads featuring the relatives of murder victims. In one, a distraught father said Kaine would not support the death penalty even for Adolf Hitler.

"The death penalty was intended to solidify part of the Republican base," said Robert D. Holsworth, director of the Center for Public Policy at Virginia Commonwealth University.

Kaine responded by airing an ad in which he told voters that he opposes capital punishment but would take an oath and enforce the death penalty. In later polls, voters said they believed Kaine's response and were angered by Kilgore's negative ads.

Kaine's victory seemed to confirm the sentiments of Virginians, the majority of whom had consistently said they were happy with the direction of the state under Warner. Kaine's effort to link himself with Warner, whose popularity has soared in his final year, appeared to work.

Warner's victory four years ago propelled him to the national stage for winning in a conservative state. He is now considering a 2008 bid for the White House.

Kaine also appeared to benefit from a national environment that has become difficult for Republicans in recent months. Bush's popularity is at its lowest levels of his presidency, and the party is struggling with several scandals involving White House and legislative leaders.

Last month, Kilgore declined to attend a speech by Bush in Norfolk, leading some to speculate he wanted to distance himself from the president. But on Monday night, Bush flew into Richmond for a dramatic, election-eve rally with thousands of supporters. In the end, it was not enough, observers said.

"Voters always use midterm elections to send a message to Washington," said Rep. Thomas M. Davis III (R-Va.).

There was a steady stream of voters from diverse backgrounds at Herndon Elementary School about 11:45 a.m. Taxes, immigration and negative campaigning shaped their views, along with this summer's decision by the Town Council to fund a center for day laborers.

Graham and Renee Inge took the day off and brought their 8-year-old daughter, Sarah, along as they cast their ballots for Kilgore. They said they were both against the day-laborers' center, and so was Kilgore. Funding a center is "kind of like, 'Sure, be illegal,' " said Graham Inge, 32, who manages a furniture store.

Voters arrived at the Seldens Landing precinct in fast-growing Loudoun at a steady pace through the morning.

"I usually go for the person, not the party, and I didn't like the way Kilgore ran his campaign. It was too negative, had too many lies," said Etta Harris, 66, of the Leisure World retirement community.

Kilgore promoted a cap on homeowners' taxes, merit pay for teachers, educational tax credits for parents who buy school supplies and local referendums to raise money for transportation projects.

But some longtime political observers complained that neither campaign honestly addressed the big issues facing the state.

"There are serious ills that have been overlooked," said Michael Carlin, a former chairman of the Fairfax County Chamber of Commerce. "What are we going to do to dramatically improve our transportation infrastructure?"

Potts entered the race in February, promising straight talk about the state budget and transportation. He vowed to stay in the race until the end, saying: "Never forget: I'm in this race to win."

As he traveled across the state, he told voters that he would raise taxes by $2 billion to pay for a massive repair of the state's transportation network. He supported abortion rights and adoption by same-sex couples. He often reserved his harshest criticism for Kilgore.

But Potts's campaign never took off, as he struggled to raise money and was denied a spot in three major debates. He repeatedly called Kilgore a coward for refusing to debate him.

With little money -- he took in a fraction of the $40 million that Kaine and Kilgore raised -- Potts aired only a few ads. A memorable one showed people banging kitchen pots and saying, "We want Potts!"

On the campaign trail, the candidates ate greasy fish at the annual Shad Planking in Wakefield and listened to music at the Galax Old Fiddler's Convention in Galax in southwest Virginia. The candidates shook hands with workers at the shipyards in Newport News and suburban commuters at the Metro stations in Northern Virginia.

Kilgore focused his efforts on the southwest corner of the state as well as in the Republican strongholds of the Shenandoah Valley, Virginia Beach and the Richmond suburbs.

Kaine targeted Richmond, where he served as mayor, the Hampton Roads area and the inner suburbs of Northern Virginia. But he also campaigned in the outer suburbs of Northern Virginia, where the GOP is typically strong.

Both Kaine and Kilgore turned to their national parties for help raising money and motivating their voting bases.

"The people of Virginia have sent a message . . . that they like the path that we chose," Timothy M. Kaine said last night.At the Richmond Marriott, as Timothy M. Kaine is declared the next governor of Virginia, an elated Sandra Whitley Ryals calls her mother with the news.

"We have not lost, and will not lose, this war," Jerry W. Kilgore said late last night. Nearby are his children, Kelsey and Klarke, and his wife, Marty.