ATLANTA — A federal judge on Thursday ordered Georgia to stop using its outdated voting machines after this year and to be ready with hand-marked paper ballots if its new system isn’t in place for the presidential primaries.

US District Judge Amy Totenberg’s 153-page ruling Thursday is not a complete victory for either side.

A federal lawsuit filed by election integrity advocates and individual Georgia voters argues that the paperless touchscreen voting machines Georgia has used since 2002 are unsecure, vulnerable to hacking and can’t be audited. They have been seeking statewide use of hand-marked paper ballots.

A law passed this year provided specifications for a new system. Secretary of State Brad Raffensperger certified a new system last week and said new machines will be in place for the state’s presidential primary election on March 24.

But the plaintiffs had asked Totenberg to order the state to immediately stop using the current system, which it plans to use for special and municipal elections this year. They also said they feared that the timeline for the implementation of the new machines is too tight, which could result in the old machines being used for 2020 elections.

Totenberg’s order made it clear that she shares that fear: She said that if the new system is not ready by March, the state cannot default to the old machines.

Lawyers for state election officials and for Fulton County, the state’s most populous county that includes most of Atlanta, argued it would be too costly, burdensome and chaotic to use an interim system for elections this fall and then switch to the new permanent system next year.

Totenberg said she believes a switch to hand-marked paper ballots for this fall would be feasible from a timing and cost perspective. But she expressed concern about the state’s capacity to manage an interim solution while also transitioning to a new system.

The integrity of Georgia’s voting system was heavily scrutinized during last year’s midterm election, in which Republican Brian Kemp, the state’s top election official at the time, narrowly defeated Democrat Stacey Abrams to become governor.

The plaintiffs in the lawsuit had asked Totenberg last August to force Georgia to use hand-marked paper ballots for that election. The judge said then she had serious concerns about vulnerabilities in the voting system and chastised state officials for ignoring evidence of the problems. But she said it would be too chaotic at that point to switch so close to the November election.