A federal judge in Kansas has halted the planned firing-squad execution of Fort Hood murderer Nidal Hasan for six months, ruling that civilian courts must have time to consider his first federal challenge to his death sentence.

The Trump administration appealed to the 10th circuit court of appeals within an hour. Justice Department officials intend to seek Supreme Court intervention if necessary to restore Thursday’s scheduled execution.

Hasan, a former US army major and psychiatrist, killed 13 people and injured 32 at the Texas base on 5 November 2009. His execution would be the first by the US military since 1961 and its first by firing squad since a 24-year-old soldier was executed for desertion in France in 1945.

District Judge Tony Mattivi’s ruling concerns access to judicial review, rather than the merits of Hasan’s claims. Although Hasan has exhausted military appeals, US law allows him to petition civilian federal courts through habeas corpus once an execution date has been set.

“Without a stay,” Mattivi wrote, “the army will execute him before any court can consider his claims.”

At Monday’s hearing in Kansas City, ACLU lawyers acting as Hasan’s standby counsel said they needed at least six months to prepare a substantial challenge. Government lawyers called the petition an unreasonable attempt to delay justice, arguing that postponement would harm victims and their families, many of whom were preparing to travel to Texas.

Mattivi rejected the government’s complaint about timing. He noted that Hasan’s allegation that Trump’s approval of his execution was motivated by racial animus concerned events after military appeals had ended. Trump approved the execution in October, as required by military law.

Hasan also alleges that Trump and defence secretary Pete Hegseth improperly interfered in execution planning. He maintains that he attacked to defend Afghan Taliban members from what he described as unlawful US military action, and that his constitutional rights were breached when he was prevented from presenting that defence at his 2013 court-martial.

The execution was scheduled for 1pm on Thursday at an undisclosed location within Fort Hood, outside Killeen. Hegseth’s October announcement that it would be livestreamed prompted international condemnation and bipartisan opposition; Trump subsequently cancelled the broadcast plan.

Hasan attacked a crowded processing centre where personnel were preparing for deployment to Afghanistan, carrying a laser-sighted handgun and almost 400 rounds. Twelve of those killed and 30 of the injured were soldiers. Military police ended the attack by shooting Hasan, leaving him paralysed from the waist down.

The immediate dispute is whether his execution can proceed before civilian courts examine the legal claims that scheduling it allowed him to bring.