High Court Judicial Commissioner Nordin Hassan said the offence was serious as it involved the safety of society.
"It has a huge impact on the country because of the constant ideological attacks by radicals," Nordin said.
He added that the sentence had to send a message over the seriousness of the offence and to ensure that others do not commit the same offence.
The teenager, whose identity was not disclosed, was not sent to the juvenile home due to the seriousness of the offence.
More From This Section
He ordered the sentence to run from the day the teenager was arrested on April 25 last year.
The teenager was arrested along with with four other adults by the Counter Terrorism Unit for an alleged conspiracy to attack government buildings, nightclubs, prostitution centres and other entertainment outlets.
The five were found in possession of chemicals and materials commonly used for making explosives.