A federal judge has blocked Secretary of Defence Pete Hegseth from lowering Senator Mark Kelly's rank in the military over his urging service members to refuse illegal orders.

US District Judge Richard Leon wrote in a scathing ruling that Hegseth had unconstitutionally retaliated against Kelly in seeking to demote the retired Navy captain.

It is another setback in President Donald Trump's fight against Kelly and five other Democratic lawmakers who published a video last year encouraging troops to disobey orders they deemed illegal, which he branded "seditious".

Earlier this week, a grand jury declined to bring charges of seditious conspiracy that federal prosecutors had sought against the six.

Reducing Kelly's rank could lead to a major cut in his retirement pay.