Thai courts dealt a double-blow to anti-government protesters on Wednesday, ordering thousands of demonstrators to leave the prime minister's offices, which they have been occupying, and issuing arrest warrants for nine leaders of the massive rallies that have gripped Bangkok.

Bangkok Civil Court issued a ruling late Wednesday ordering the nearly 5,000 protesters from the People's Alliance for Democracy to immediately leave the prime minister's compound and also stop blocking the surrounding public streets.

The alliance, a group mainly comprising royalists and pro-military business interests, staged the demonstrations with the aim of overthrowing the seven-month-old government of Thai Prime Minister Samak Sundaravej.

Earlier in the day, Thailand's Criminal Court ordered the arrest of the group's leaders on charges including inciting unrest and attempting to overthrow the government, which can carry the death penalty upon conviction.

Protesters have camped in a huge garden outside the Government House offices since scaling fences there Tuesday afternoon.

About 500 riot police forced their way into the compound overnight, briefly clashing with protesters. Police later backed off from the confrontation, establishing themselves inside the compound and mingling with the demonstrators.

It was unclear whether police would try to enforce the arrest warrants. Samak said Tuesday that the authorities would avoid using force against the demonstrators.

The protest leaders said the rallies would continue even if they are arrested.

"We are ready to spend time in jail," Chamlong Srimuang, one of the leaders, told a crowd assembled inside the government compound in Bangkok. "The [alliance] will continue to protest until our demands are met. This government has to resign."

The People's Alliance for Democracy has condemned Samak's coalition as merely a proxy for former prime minister Thaksin Shinawatra.

The right-wing group, despite its name, is demanding parliamentarians be appointed instead of elected.

Thaksin, one of Thailand's richest men, is in self-imposed exile in England to avoid facing corruption and tax evasion charges in his home country. He was forced out of elected office in a 2006 coup that began with similar street protests.

With files from the Associated Press