(Reuters) - A federal judge on Thursday ordered Georgia to be ready to use handmarked ballots in next year’s presidential primary in case a new $106 million voting system is not ready in time for its 2020 Democratic nominating contest.

In a long-running dispute over Georgia’s voting system, the judge banned use of the paperless voting machines after 2019, but denied a request to bar them for municipal elections this November.

The state’s “long and twisted saga” of voting systems “is finally headed towards its conclusion,” U.S. District Court Judge Amy Totenberg wrote in a 153-page ruling.

Georgia, one of five states to use touchscreen machines with no paper record, has used direct-recording electronic voting machines since 2002. The machines have drawn criticism from various advocacy groups and federal agencies, including U.S. Department of Homeland Security officials.

The state earlier this year ordered a new voting system with ballot-marking devices, which Secretary of State Brad Raffensperger has said will be installed in time for the March 24 presidential primary.

Both sides expressed satisfaction with the judge’s split ruling, with Raffensperger accusing critics of using “scare tactics to try to undermine Georgia elections,” and the plaintiffs crediting the court with prodding the state into action.

The Coalition for Good Governance, a voting-rights group, and several Georgia voters, filed the lawsuit in 2017.

“This is a big win for all Georgia voters and those working across the country to secure elections and protect the right to vote,” said Washington-based attorney David Cross who represents some of the plaintiffs.

Totenberg previously denied a plaintiff’s request to force Georgia to use paper ballots in the 2018 congressional election, citing the potential for last-minute confusion.

In her latest ruling, Totenberg also ordered the state to “address significant deficiencies in the voter registration database” and its ExpressPoll system which is used to check voters in to their precincts.

During the November election, various problems were reported with voter registration and the ExpressPoll systems in several counties.