MIAMI — A federal appeals court ruled on Monday that the 17-year prison sentence imposed on Jose Padilla, who was convicted of terrorism conspiracy in 2007, was too lenient and sent the case back to the district court here for a new hearing.

In a 2-to-1 opinion, the United States Court of Appeals for the 11th Circuit, in Atlanta, ruled that the sentence was “substantively unreasonable” and did not take into account Mr. Padilla’s violent criminal history as a former gang member in Chicago. It also said the lower court did not take seriously enough Mr. Padilla’s time at a Qaeda camp in Afghanistan, where he was trained to kill.

“Padilla poses a heightened risk of future dangerousness due to his Al Qaeda training,” the court said. “He is far more sophisticated than an individual convicted of an ordinary street crime.”

The appellate court also affirmed Mr. Padilla’s conviction and that of his two co-defendants.

The government had appealed Mr. Padilla’s sentence, which was 17 years and 4 months, seeing it as too great a departure from federal sentencing guidelines.