A Malaysian court ordered the editor of an anti-government news Web site released from detention Friday, ruling that his arrest under a law allowing indefinite incarceration was unlawful, a lawyer said.

Shah Alam High Court Justice Syed Ahmad Helmy Syed Ahmad ruled that the home minister acted outside his powers in having Raja Petra Kamaruddin arrested Sept. 12 for allegedly causing racial tensions, said Raja Petra's lawyer, Malik Imtiaz Sarwar.

"It's a historic ruling and definitely a wonderful step in terms of civil liberties in Malaysia," Malik Imtiaz said.

He quoted the judge as saying the grounds given for Raja Petra's detention were insufficient and his arrest under the Internal Security Act was unlawful.

The ISA allows the government to detain anyone for an initial two-year period without charges and to extend the detention indefinitely.

Raja Petra, who was accused of threatening public security and causing racial tension by publishing writings that ridiculed Islam in this Mulsim-majority country, was to be taken to court later Friday to be formally set free.

It's not the first time that a court has ordered the release of ISA detainees, and the ruling also does not prevent the government from rearresting him under the ISA. The government can also appeal the ruling.

Raja Petra, 58, has increasingly infuriated authorities by publishing numerous claims about alleged wrongdoing by government leaders on his highly popular site, Malaysia Today. The government has denounced most of Raja Petra's allegations as lies.

He is also on trial in a separate case, having been accused of sedition by implying that Deputy Prime Minister Najib Razak was involved in the murder of a Mongolian woman. Raja Petra denies the allegation. If convicted, he faces up to three years in jail.

The legal controversies come at a time when the government's popularity has hit at an all-time low while the ruling party is riven with factional fighting and faces the threat of being ousted by the opposition.

The Internal Security Act is a holdover from British colonial days, when it was used against communist insurgents. Independent Malaysia's postcolonial government has kept the act in the statute books and has used it sparingly against political dissidents, ignoring calls from opposition groups and others to disband the law.

Raja Petra's arrest triggered widespread protests by civil society groups, lawyers and other online commentators.

Some of Malaysia's most popular blogs offer strong anti-government commentaries and present themselves as a substitute for mainstream media, which are controlled by political parties or closely linked to them.

The government estimates there are more than 700 Malaysians who blog on social and political issues.