A court in Sale, near the capital Rabat, condemned the six Moroccans late on Thursday and also fined them 10 000 dirhams (115 euros) each for "incitement of terrorist acts".
Lawyer Abdessamad El Idrissi, a member of the Islamist PJD (Justice and Development Party), criticised what he called the "exaggerated and sorry" sentencing of the young Moroccans who "represent the country's elite".
They were convicted for having hailed in comments on Facebook the murder in Ankara of ambassador Andrei Karlov by an assailant shouting "Allahu Akbar!" (God is Greatest), and condemning Russian military deployment in support of the regime in the Syrian conflict.
The six were detained shortly after the murder, sparking criticism from within the PJD which heads Morocco's ruling coalition.
Russian President Vladimir Putin appointed a new ambassador to Turkey last month.