RICHMOND, Va. (AP) — A Republican won a Virginia state House of Delegates race so close that its outcome was determined by pulling his name out of a ceramic bowl Thursday.

The win allows the Republicans to maintain a slim majority in the House, though a final tally is still uncertain because another close race is locked in a court battle and the Democrat in the race can ask for yet another recount.

Del. David Yancey’s named was chosen out of a ceramic bowl, making him the winner of the 94th District race. The name of each candidate was printed on a piece of paper and placed into separate film canisters. The canisters were put into a cobalt-blue-and-white ceramic bowl made by a local artist, stirred around and Yancey’s name was chosen first.

It’s been nearly 50 years since a legislative seat was settled by drawing lots in Virginia.

The race between Yancey, a three-term incumbent, and Democratic challenger Shelly Simonds has bounced back and forth since the November election, when Virginia Democrats — fueled by voter anger directed at Republican President Donald Trump — wiped out a 66-34 advantage held by Republicans in the House. The election has been widely seen as a potential harbinger of the 2018 midterm congressional elections.

Simonds appeared to have lost the November election by 10 votes, but on Dec. 19, she won a recount by a single vote. The next day, a three-judge panel in Newport News declared a tie based on a previously uncounted vote for Yancey.

With Yancey’s win, Republicans hold a slim, 51-49 advantage over Democrats in the Virginia House. But the race may not be over. Simonds could ask for another recount, a move that would likely delay a winner being declared before the 2018 legislative session begins next week. That would still allow Republicans to elect a speaker and make committee assignments based on a 50-49 advantage.

The balance of power in the House could shift again because a lawsuit is pending over the results of another House race in Northern Virginia. Democrat Joshua Cole lost to Republican Bob Thomas by 73 votes in a recount. But voters filed a federal lawsuit after at least 147 ballots were found to be assigned to the wrong districts. A federal court hearing on that election is schedule for Friday.

The General Assembly is set to reconvene Wednesday.

A similar tie vote was settled by lot at least once before in Virginia. In 1971, Republican William H. Moss Sr. appeared to lose the election for a seat in northern Virginia. But after a recount ended in a tie, Moss was declared the winner after a blindfolded state elections official pulled his name out of a large decorative cup, according to news reports at the time.

(© Copyright 2018 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)