Abdiaziz Abdullahi was convicted of five counts—including illegal possession of six hand grenades, an AK-47 rifle and 270 bullets.
Senior principal magistrate Francis Kyambia said Abdullahi deserved the punishment considering the seriousness of the offenses.
Police said Abdullahi was found with a vehicle loaded with explosives, which was later detonated by the Anti-Terrorism Police Unit (ATPU).
Abdullahi was charged alongside Isaak Noor who was acquitted after the prosecution failed to link him to the crimes.