Chants of "Down with the military judge" rang out from the public gallery as the sentence was read out.
Ayari was prosecuted over blogs he had written alleging financial abuses by army officers and defence ministry officials in a case that Human Rights Watch described as "not worthy of the new Tunisia".
The 33-year-old is himself the son of an army colonel who was killed in a May 2011 clash with jihadists.
But following his return to Tunis in December, a retrial was ordered and he was sentenced to a year in prison the following month.
Ayari has alleged that he is being punished for blogs that he wrote while out of the country that were critical of the anti-Islamist Nida Tounes party of President Beji Caid Essebsi, who won a December election
He is a supporter of former president Moncef Marzouki, a secular leftist who ruled in alliance with the moderate Islamist Ennahda party but was defeated by Essebsi.
His supporters charge that his prosecution is a violation of the newfound freedom of expression which was one of the main gains of the revolution.
Human Rights Watch has called on parliament to reform laws that lead to imprisonment for defaming or insulting state institutions, and to end jurisdiction of military courts over civilians.
