Cheikh Baye Ould Mohamed was found guilty of "violence against a public official in the exercise of his duties" following a one-day trial in the capital Nouakchott, the sources said.
He was arrested after lobbing his shoe in the direction of a government spokesman during a press conference on June 30 and calling him a "minister of lies".
Supporters of Ould Mohamed - many of them fellow members of an opposition youth group - jeered and loudly protested as the verdict was read out.
He said the judge had gone beyond the punishment demanded by prosecutors, who had called for a minimum sentence.
"It's an unfair and excessive decision," added another defence lawyer, Yarba Ould Ahmed Saleh.
Ould Mohamed, who is in his thirties, runs a news website called "Meyadine" and is a member of the so-called "February 25 Movement" which opposes the rule of President Mohamed Ould Abdel Aziz.