A federal judge on Sunday threw out a Justice Department lawsuit that sought to postpone certification of Alaska's Senate election, dealing a setback to the Trump administration just two days before the midterm contests. The department said it plans to appeal.

The legal fight grew out of an unusual name collision on the ballot. Republican Sen. Dan S. Sullivan faced a challenge from Daniel J. Sullivan Jr., a similarity that prompted critics to label the challenger Decoy Dan. Federal lawyers asked the court to delay or block certification while investigators examined whether confused voters might have changed the result.

U.S. District Judge Sharon Gleason ruled that the government failed to explain how its proposed investigation could determine what voters intended without breaching the secrecy of the ballot. She added that the remedy the administration wanted would interfere with Alaska's own authority to administer its elections.

The Justice Department responded that the case was dismissed on procedural grounds and that the judge never addressed its central allegation, namely that Sullivan Jr. joined the race in order to mislead voters. The dispute will now move to the 9th U.S. Circuit Court of Appeals.

The controversy has shaken the campaign in its closing days. The New York Times reported that individuals linked to Democratic nominee Mary Peltola's campaign assisted in recruiting Sullivan Jr. to run as a spoiler candidate. Peltola has denied any role in the effort, and Sullivan Jr. has denied coordinating with her team.

Sen. Sullivan said Sunday that he would accept the outcome of Tuesday's election, even as the administration presses ahead with a criminal investigation into his challenger's candidacy. Sullivan accused Sullivan Jr. of deliberately trying to sow confusion among voters.

Alaska Gov. Mike Dunleavy, a Republican, has indicated he might decline to certify a victory by Peltola. Asked about that possibility, Sullivan would not say whether he would back an effort to withhold certification.

The outcome of the race could play a part in deciding which party holds the majority in the Senate.

Alaska conducts its elections through ranked-choice voting. If no candidate secures a majority on the initial count, the contender in last place is dropped and the next preferences marked on those ballots are then tallied, a process that can stretch out the final result.