(CNN) -- Calling the case a "law enforcement matter, not a military matter," a federal judge in South Carolina has ruled that the U.S. government cannot continue to hold "enemy combatant" Jose Padilla without charging him with a crime.

The ruling says the government has 45 days to do so or Padilla would be eligible for release. The government vowed to appeal the ruling.

The order from U.S. District Judge Henry Floyd sided with defense attorneys who advanced that argument in a hearing last month in Spartanburg, South Carolina, the jurisdiction where Padilla has been detained for 2 1/2 years as a military prisoner.

The Supreme Court ordered last June that the challenge, which originated in New York, be heard there.

Padilla, a 34-year-old American suspected of plotting with al Qaeda to detonate a radioactive "dirty bomb" and to blow up apartment buildings in the United States, was arrested in May 2002 upon landing on an overseas flight to Chicago.

He was initially transferred to New York as a material witness in the grand jury investigation into the Sept. 11, 2001, terrorist attacks and has never faced criminal charges.

"His alleged terrorist plans were thwarted at the time of his arrest. There were no impediments whatsoever to the government bringing charges against him for any one or all of the array of heinous crimes that he has been effectively accused of committing," Judge Floyd found.

"Since (Padilla's) alleged terrorist plans were thwarted when he was arrested on the material witness warrant, the court finds that the president's subsequent decision to detain (him) as an enemy combatant was neither necessary nor appropriate," the judge wrote.

It was one month after Padilla's arrest when President Bush declared him a "grave threat" to national security and transferred him to military custody at the Charleston Naval Brig in South Carolina. Padilla was denied access to an attorney for two years.

Padilla defense attorney Donna Newman applauded Monday's ruling, saying it "is confirmation that the Constitution is alive and well and kicking."

"If you want to hold him, you have to charge him with a crime," she said.

The case would likely be heard next by the 4th U.S. Circuit Court of Appeals in Richmond.

The government has argued that the president's constitutional authority as commander-in-chief and Congress's authorization for the use of military force against the perpetrators of the Sept. 11 attacks are lawful grounds for Bush's action.

But Floyd drew a distinction between combatants captured during military operations abroad and suspected terrorists arrested on American soil.

He relied on the Supreme Court's ruling in the parallel enemy combatant case of Yaser Hamdi, in which the majority decision declared a "state of war is not a blank check for the president when it comes to the rights of the nation's citizens." Both Hamdi and Padilla are U.S. citizens.

"To be more specific," Floyd wrote, "whereas it may be a necessary and appropriate use of force to detain a United States citizen who is captured on the battlefield, this court cannot find, in narrow circumstances presented in this case, that the same is true when a United States citizen is arrested in a civilian setting such as an United States airport."

The high court has held the president does have the authority to detain "enemy combatants" captured on the battlefield, but even then the detainee is entitled to a fact-finding hearing. The government avoided such a hearing in Hamdi's case by releasing him to his native Saudi Arabia last October.

Padilla's attorneys have always maintained that presidential authority does not extend to American citizens caught on American soil, and unlike Hamdi, who was allegedly carrying a Kalashnikov assault rifle and traveling with Taliban troops, Padilla was carrying no weapons and wearing civilian clothes.

"It is true that, under some circumstances, such as those present in Hamdi, the president can indeed hold an United States citizen as an enemy combatant. Just because something is sometimes true, however, does not mean that it is always true," Floyd wrote.

"The president's use of force to capture Mr. Hamdi was necessary and appropriate. Here, that same use of force was not," the judge wrote.

Floyd said if the purpose of Padilla's indefinite detention is to prevent him from rejoining his alleged al Qaeda confederates, then the president ought to ask Congress to pass a law allowing him to do so.

"If the law in its current state is found by the president to be insufficient to protect this country from terrorist plots, such as the one alleged here, then the president should prevail upon Congress to remedy the problem," Floyd wrote.

"It is true that there may be times during which it is necessary to give the executive branch greater power than at other times. Such a granting of power, however, is in the province of the legislature and no one else -- not the court and not the president," he wrote.