Virginia settled the outcome of a tied House of Delegates race that would determine control of the chamber in a random drawing Thursday — and Republicans won.

In accordance with state law, once a recount determined that the race between Delegate David Yancey (R) and Shelly Simonds (D) is tied at 11,608 votes for each candidate, the outcome was settled by the state’s board of elections with a random drawing.

Papers with each of their names were placed in film canisters and put into a bowl, and one canister was drawn at random. That turned out to be the one containing Yancey’s name.

The result means Republicans will hold a 51-49 majority in Virginia’s state house this year, unless further legal proceedings change the outcome of any remaining races.

Democrats made big statehouse gains in Virginia’s elections — but some races remained to be decided

Back in November, during Virginia’s 2017 election night, it was clear Democrats had not only held the governorship but had made huge, stunning gains in the state’s House of Delegates — the lower chamber of the state legislature.

Yet it wasn’t clear exactly how huge those gains were — or whether they’d be sufficient to break the Republican Party’s hold on the chamber, because some close races were headed for recounts.

Going in, the GOP held a 66-to-34 majority. And when the dust settled after the initial days of vote counting, it looked like they had just barely held on to it. Democrats had flipped at least 15 GOP-held seats, far more than political analysts expected beforehand. Still, in initial tallies, Republican candidates led in races for 51 seats in the chamber, compared to 49 for Democrats.

But some of these races were remarkably close — particularly the one in the 94th District, representing the city of Newport News in the southeast of the state.

There, incumbent Delegate David Yancey (R) led his challenger Shelly Simonds (D) by a mere 10 votes heading into a recount. That’s the sort of margin that often shifts during a recount, due to errors in the initial tally.

The 94th District recount tipped the race to the Democrat. Then the judges made it tied again.

So the recount for the 94th District took place in December — with observers and lawyers from both campaigns, as well as many journalists, in attendance so as to prevent any mischief. And at the end, the margin shifted just enough to give Simonds the victory — 11,608 votes to 11,607.

That, it seemed, would have flipped a 16th GOP-held seat to the Democrats and put the House of Delegates at 50 seats for each party.

But when the outcome was presented to judges, Yancey’s campaign argued that one ballot hadn’t been counted, but should have been. The ballot had bubbles for both Yancey and Simonds filled in, but there was a line drawn through the bubble for Simonds — suggesting that the voter may have crossed out his or her Simonds vote.

The Virginia Pilot’s Jordan Pascale obtained the ballot:

BREAKING: We obtained the actual ballot submitted to the court.

Dissect away.https://t.co/cQneTM0tUk pic.twitter.com/Eeq4mEOtd9 — Jordan Pascale (@JWPascale) December 20, 2017

The recount overseers hadn’t counted this ballot, but the judges sided with Yancey and agreed that that seems like it was meant to be a vote cast for him. And since that would make the race tied at 11,608 votes to 11,608, they declined to certify a winner.

So in accordance with state law, the board of elections held a random drawing to determine which candidate would win — and Yancey got lucky.

Republican David Yancey is declared winner of tied Virginia delegate election after his name drawn from a bowl pic.twitter.com/zRQQVLYT4n — Robert Maguire (@RobertMaguire_) January 4, 2018

It seems, then, that Republicans will control the barest of majorities in both the state house and state senate this year — 51-to-49 in the former chamber, and 21-to-19 in the latter. (The state Senate wasn’t up for election last year, and won’t be until 2019.) So Democratic Gov.-elect Ralph Northam will have to deal with a very narrowly divided legislature to sign anything into law.