The prosecutor had called for a 10-year sentence for Abdelghani Aloui, 25, who told the court he had "no regrets" about his actions.
Signup to our newsletter and follow us on Facebook and Twitter!
The blogger, who spent seven months in detention awaiting trial, was found guilty of insulting the army but acquitted of defending "terrorist acts aimed at damaging symbols of the republic".
The defence had argued that the young man had the right to freedom of expression under the Algerian constitution.
The accused had posted a Facebook page in November 2012 called the "Algerian Free Electronic Army".