A Singaporean teenage blogger who was jailed twice for his online posts insulting his government was granted asylum to remain in the United States, an immigration judge in Chicago ruled.

Amos Yee was jailed in 2015 for four weeks for hurting the religious feelings of Christians and posting an obscene image as part of his attacks on the island's late leader Lee Kuan Yew - whose son Lee Hsien Loong is now the prime minister.

He was jailed again in 2016 for six weeks for insulting Muslims and Christians in a series of videos posted online, but critics claim the real reason was to silence him.

Judge Samuel Cole issued a 13-page decision on Friday, more than two weeks after Yee's closed-door hearing on the asylum application. 

"Yee has met his burden of showing that he suffered past persecution on account of his political opinion and has a well-founded fear of future persecution in Singapore," Cole wrote.

Cole said testimony during Yee's hearing showed that while the Singapore government's stated reason for punishing him involved religion, "its real purpose was to stifle Yee's political speech".

READ MORE: Obedience and uncertainty in Singapore

He said Yee's prison sentence was "unusually long and harsh" especially for his age.

Department of Homeland Security attorneys had opposed the asylum bid, saying Yee's case didn't qualify as persecution based on political beliefs.

It was unclear whether they would appeal the decision or if Yee would have to remain imprisoned if they did. Attorneys have 30 days to appeal.

Singapore, an island republic of 5.6 million which has long been been criticised for strict controls on dissent, takes pride in its racial and social cohesion, which it regards as essential for stability in a volatile region.

Source: News agencies