Not content with lese-majeste laws to protect the revered monarchy that are among the world's most draconian, Thailand is to build a wall around the kingdom to keep out detractors.

But the barrier will be virtual, a national internet firewall to block websites deemed insulting to the throne of King Bhumibol Adulyadej, who at 80 is the world's longest serving monarch.

For the princely sum of almost £9m the Thai information ministry will shield the king and his adoring subjects from the sleights – real or perceived – of those who mock online.

Thailand's government, locked in a bitter struggle with staunchly royalist demonstrators who have been on the streets for months, has been accused of harbouring republican tendencies and being hostile to the monarchy.

It refutes the charge, but the move to construct the firewall appears to be the result of pressure from the powerful military and its demand that criticism of the monarchy be stamped out.

The firewall will also give Thailand's bureaucrats the power to block other websites it labels inappropriate, like those run by perceived terrorist groups or showing pornography. But the first target will up to 1,000 websites suspected of carrying material regarded as offensive to the king.

Last year the government, which was appointed by the military after a coup in 2006, blocked the YouTube website for weeks after its parent company, Google, refused to take down a posting.

The 44-second clip showed a picture of the Thai king with a pair of women's feet suspended above his head. In Thai culture feet are regarded as dirty and the lowest part of the body.

Thailand's lese-majeste laws are harsh by any standard, promising 15 years imprisonment for anyone who "insults, defames or threatens" the royal family.

But the law allows anyone to make an accusation against anyone else, with the result that it is often abused to ensnare rivals.

The Thai prime minister, Somchai Wongsawat, has ordered police to be especially vigilant and special branch are monitoring community radio stations suspected of airing lese majeste content.