Democrat Lynwood W. Lewis Jr. thanks supporters and staff for their efforts during his victory celebration on Jan. 7 at Guad's in Norfolk, Va. (Stephen M. Katz/Associated Press)

Democrats prepared to seize control of the Virginia Senate on Monday after winning a recount by just 11 votes in a razor-thin special election, giving Democratic Gov. Terry McAuliffe’s first-year agenda a crucial boost.

The win energizes a party that in recent years has had to depend on moderate GOP allies in the Senate to flex any legislative muscle in Richmond — even as Democrats have won every statewide election since 2012.

Although Republicans still overwhelmingly control the House of Delegates, Monday’s victory gives McAuliffe and his party new leverage as they try to expand Medicaid under the Affordable Care Act, grant new rights to same-sex couples and increase public school funding.

Both parties closely watched the recount in the Hampton Roads-based district because of its outsize importance to the balance of power in the Capitol.

Going into it, Del. Lynwood W. Lewis Jr. (D-Accomack) was ahead of Republican businessman Wayne Coleman by just nine votes. His lead grew to 11 by the end Monday after officials recounted some votes by hand and teams of lawyers from both sides wrangled over a handful of contested ballots. The final tally was 10,203 votes for Lewis and 10,192 for Coleman.

An unidentified woman steps over an icy puddle after casting her ballot in the special election for the District 6 seat of the Virginia Senate at the Onley, Va., polling site on Jan. 7. (Jay Diem/Associated Press)

In an interview, Lewis declined to weigh in on the partisan implications of his victory and said he plans to work with “anybody who will advance the interests of the people I represent.” He said diversification of the Hampton Roads economy, long-dependent on defense spending, will be a major focus. “My top priority is representing my people and working hard for my people.”

Lewis had been certified the winner of the Jan. 7 contest to fill the state Senate seat vacated this month by Lt. Gov. Ralph S. Northam (D). But the slim margin entitled Coleman to a publicly funded recount.

The recount became all the more crucial last week, when Democrats kept the Northern Virginia seat previously held by Attorney General Mark R. Herring (D).

Now the chamber will remain evenly split, 20-20, but power will shift to Democrats because Northam, who presides over the Senate, has the authority to break most tie votes.

Before Northam’s inauguration this month, Republicans controlled the chamber with the tie-breaking vote of his predecessor, Republican Bill Bolling.

“We’re extremely happy with the results. We’ll have more to say about it tomorrow at noon,” said Senate Democratic leader Richard L. Saslaw (Fairfax), referring to the hour that the Senate will convene.

The mechanics of how Democrats will use their new majority to seize power in the Senate through committee chairmanships and other crucial leadership roles remained secret late Monday. Democrats were bracing for a parliamentary fight with Republicans.

Some Republicans have suggested that Democrats need a two-thirds majority to make an off-cycle change to committee assignments, which are crucial for determining which bills are killed and which make it to the Senate floor for a vote by the whole chamber.

In early 2012, after the last election of the full Senate, Republicans took control of the chamber — including leadership positions and committee chairmanships — with Bolling’s support. Democrats argued then that the lieutenant governor was not allowed to vote in such organizational matters, but Republicans disputed that.

Democrats and Republicans are expected to flip-flop on that legal analysis this time as they argue for and against reorganization with the lieutenant governor’s help.

Two Democrats with direct knowledge of their strategy said they agree that a two-thirds majority is required under current Senate rules to pull individual senators off committee assignments. But only a simple majority is needed to throw out the entire set of rules and write new ones, the Democrats said — which is exactly what they plan to do.

Even some in the GOP were assuming late Monday that Democrats would prevail — and that a new, more partisan atmosphere would descend on the Capitol.

“What we may begin to see is a bit of a stalemate on some areas where there’s a philosophical disagreement between Republicans and Democrats,” said Sen. Richard H. Black (R-Loudoun). “I think you will see the House of Delegates digging in their heels, and then I think you’ll see the Senate digging in their heels.”

McAuliffe, for his part, declined to crow about the victory.

“I am glad that the process of filling each vacant seat in the General Assembly is now complete,” the governor said in an e-mailed statement, “and I look forward to working with Lynwood and members of both parties in the General Assembly to tackle the challenges facing Virginia’s economy and communities.”

Each locality in the 6th Senate District began recounting its ballots at 8 a.m. Monday, with representatives from both campaigns on hand to observe. Election officials pored over voting-machine tallies and individual ballots in a district that includes parts of Norfolk, Virginia Beach and the Eastern Shore.

Nearly 10 hours later, the process wrapped up with Lewis two votes richer.

The legal teams battled over whether ballots should be counted because of various alleged flaws, including smudges or “x” marks instead of filled-in bubbles by a candidate’s name. The arguments continued after it became clear that Coleman could not win even if every disputed ballot went his way.

Coleman, who spent the day observing the recount at courthouses in Norfolk and Virginia Beach, left after a three-judge panel gave the last of the disputed ballots to his Democratic rival.

“I’m disappointed for the folks who voted for me,” Coleman said. “But we improved the system with this race and surprised a lot of people.”

Austin Chambers, campaign manager for Coleman, said there were a number of problems in Norfolk during the recount, including instances in which the number of voters checked in with poll books at certain precincts did not match the number of ballots cast.

Chambers also said the machine used to recount absentee ballots was broken, so they were recounted twice by hand. The hand recount yielded a different result each time, so the ballots were recounted a third time with the machine, which had been fixed, Chambers said.

A similar procedure unfolded on a statewide scale last month as Herring’s victory in the attorney general’s race was decided by a recount.

Coleman’s attorneys raised questions about four voting machines that had been taken to Norfolk polling places as backups but had not been used. The lawyers asked elections officials to review the tapes produced by the machines to double-check that they had recorded no votes.

Elections officials said that request was a first, but they complied, saying that they understood in a race this close that there was no room for error. Coleman’s team had also asked that Accomack County votes be recounted by hand because an optical-scanning machine had missed one write-in vote. The judges denied that request.

Michael Laris and Rachel Weiner contributed to this report.