A Moroccan convicted of belonging to a terrorist cell that included three Sept. 11 hijackers was freed from prison Tuesday after a federal court ruled he shouldn't be jailed with appeals still pending.

Mounir el Motassadeq, 31, was sentenced to seven years in prison in August by a court in Hamburg.

A statement by Germany's Federal Constitutional Court said the lower court had been wrong to order el Motassadeq returned to custody because appeals by both the defense and prosecutors were still pending.

The ruling, which does not affect the Moroccan's conviction, adds another twist to a tangled legal saga that started with el Motassadeq's arrest in the northern port city in November 2001.

In 2003, he became the first person anywhere to be convicted in connection with the Sept. 11 attacks when he was found guilty of membership in a terrorist organization.

Another federal court overturned his conviction the following year and ordered a retrial. He was again found guilty. Appeals from both his defense lawyers and prosecutors are still pending.

El Motassadeq was accused of helping pay tuition and other bills for cell members to allow them to live as students while they plotted the attacks. Prosecutors had demanded his conviction on all the charges and the maximum sentence of 15 years in prison.

The Moroccan acknowledges he was close to the hijackers but insists he knew nothing of their plans. Defense lawyers criticized the lack of direct testimony from witnesses such as Ramzi Binalshibh, a key Sept. 11 suspect held by the U.S.

The Hamburg state court acquitted him of direct involvement in the attacks, finding him not guilty of more than 3,000 counts of accessory to murder.

El Motassadeq spent about 2 1/2 years in prison between his arrest and his release in April 2004, and has been jailed again since his conviction in August.

A statement from the federal court said it agreed with a complaint from el Motassadeq that the Hamburg judges had been wrong to order him to return to custody pending his appeal.

"The fact that a (not yet final) verdict was issued or that prosecutors have sought a higher sentence does not suffice to cancel the exemption from imprisonment granted earlier," the court said.

Detaining the defendant "infringed on his basic right to liberty," it said.