The websites of Singapore's president and prime minister have been hacked after PM vowed to crack down on activist group Anonymous, which is demanding greater Internet freedom in the city-state, officials confirmed on Friday.

A "subpage" of the website of the Istana, the official residence of President Tony Tan, was "compromised" early Friday, telecommunication officials said without giving details.

The hacking happened about an hour after Prime Minister Lee Hsien Loong's website displayed mocking messages and pictures from Anonymous, which is demanding the scrapping of rules requiring Singapore news websites to obtain annual licenses.

The rules, which came into effect in June, have sparked anger among some bloggers and activists who say they are designed to muzzle free expression.

While the defaced section of www.istana.gov.sg had been take offline by early afternoon, screengrabs widely circulated on social media showed the image of a stern-looking elderly woman raising a middle finger. Its authenticity could not be independently verified.

It was accompanied by the words "JIAK LIAO BEE!", a mildly offensive term in Hokkien, a southern Chinese dialect, referring to people who get paid for doing nothing.

Unlike the hacking of the prime minister's website, there was no indication of the involvement of Anonymous in the attack on the Istana page.

"Both the PMO (prime minister's office) and Istana main websites are still working, and we will restore the compromised pages as soon as possible. The matter is under investigation," the Infocomm Development Authority of Singapore (IDA) said in a statement.

"We will continue to strengthen all Government websites. This includes the checking and fixing of vulnerabilities and software patching," it said.

The defaced section of Lee's official website www.pmo.gov.sg showed the message "ANONYMOUS SG WAS HERE BIATCH".

"It's great to be Singaporean today," read a headline next to Anonymous' trademark Guy Fawkes mask, a symbol of anti-establishment defiance worldwide.

The double attacks came after Lee on Wednesday told local journalists that his government would "spare no effort" in going after Anonymous members who had threatened to wage a cyber war against the government.

A person claiming to be from Anonymous last week threatened to mount the attacks to protest recent licensing rules for news websites.

In the video posted on YouTube on October 31, a person speaking with a computer-digitised voice and wearing a Guy Fawkes mask said the group would "go to war" with the Singapore government.

A day later, a person claiming to be affiliated with Anonymous hacked the official blog of the Straits Times' technology correspondent.

The hacker also warned of further attacks on the tightly governed island's technological infrastructure if its demands were not met.

Singapore strictly regulates the traditional media, but insists the new licensing rules do not impinge on Internet freedom.