Virginia Republicans have maintained control of the state Senate after a bruising, expensive contest.
All Republican incumbents won, and GOP candidate Glen Sturtevant won a key open seat in the Richmond area to cement the party's control of the upper chamber.
Democratic Gov. Terry McAuliffe led a well-financed effort, with help from deep-pocketed donors and former New York City Mayor Michael Bloomberg's gun control group, to help his party in a handful of competitive races.
But Sturtevant, boosted by the Republican State Leadership Committee, a Washington-based GOP group largely backed by corporate interests, was able to defeat Democrat Dan Gecker. Sturtevant leads Gecker 50 percent to 47 percent with 99 percent of the vote counted.
Republicans currently have a 21-19 advantage in the state Senate, but Democrats could have taken control by gaining one seat thanks to Democratic Lt. Gov. Ralph Northam's status as a tiebreaker.
In the House, the GOP maintained a clear advantage.
Democrat Jeremy McPike kept a key Northern Virginia Senate seat in his party's hands, defeating Republican Hal Parrish.
With 84 percent of precincts reporting, McPike had 54 percent of the vote, compared to 46 percent for Parrish.
The race attracted more than $1 million in campaign spending, as Republicans nominated Parrish, a popular mayor of Manassas to try to wrest the seat from Democrats. The Parrish family has held elected office in Manassas and Prince William County for decades.
The seat had previously been held by 89-year-old Democrat Charles Colgan, the longest serving state senator in Virginia history, who opted not to run for re-election.
The district profile tilts strongly toward Democrats, and McPike ran a campaign centered on education and transportation issues.
With Republicans maintaining control of the General Assembly, McAuliffe lost a chance to gain leverage when negotiating with GOP lawmakers on matters like the state budget during the last two years of his term. And his top legislative priorities, like expanding Medicaid coverage or passing tighter gun laws, remain out of reach.
Election Day was a test for McAuliffe's efforts to build a lasting advantage over Republicans in terms of campaign field work. The governor has often touted his heavy investment in data-driven voter identification and get-out-the-vote efforts that could be used to strengthen Democratic efforts in future contests. Virginia is expected to be a key swing state, and Hillary Rodham Clinton, a close friend of McAuliffe, is the favorite to be the Democratic nominee in the 2016 presidential contest.
McAuliffe was able to tap his rolodex of wealthy donors from his days as a prominent national Democratic fundraiser with close ties to Clinton and her husband, former President Bill Clinton.
Virginia's legislative contest also became a spending war between well-funded national gun control and gun rights groups.
Bloomberg's gun control group entered the race in the final weeks, announcing it was going to spend $2.2 million helping Democrats in two key Senate races. Some of the group's ads featured the father of a Roanoke journalist who was shot to death on live TV in August and denounced the Republican candidates as being beholden to the gun lobby.
The National Rifle Association has also spent heavily promoting GOP lawmakers.
Other outside groups that have been active in key Senate races included Americans for Prosperity, which is backed by conservative billionaires Charles and David Koch, and NextGen Climate Action, backed by billionaire environmentalist Tom Steyer.
Some of Tuesday's Senate contests were likely among the most expensive in Virginia's history. Virginia candidates and outside groups spent more than $10 million running more than 20,000 TV ads this election season, according to media tracking data analyzed by the Center for Public Integrity.