The regional court in Winterthur on Tuesday handed down the sentences after the men were found guilty of false imprisonment and intimidation.
The men will also have to pay a financial penalty if they re-offend during while on probation. In addition, two of the men, an Afghan and a Macedonian, must now leave Switzerland and will not be allowed to return for seven years.
In a related sentence, a young man who was still 17 at the time of the attack was given a six-month suspended prison term for his part in the attack. He has been ordered to undergo counselling and is forbidden from having contact with anyone in the Winterthur Islamist community.
A further two men were found not guilty of taking part in the assault at the city's An'Nur mosque. The mosque had been the focus of a number of police operations over alleged links to radical Islam and closed its doors for good in the middle of last year.
The attackers are said to have forced one of their victims to swallow a banknote, while their other victim suffered concussion after being assaulted.
The two were attacked after allegedly tipping over a journalist about a sermon in which an imam at the mosque called for the killing and burning of Muslims who did not participate in communal prayer, and for others to denounce such people.
That imam, a 25-year-old Ethiopian, was found guilty of incitement to violence in 2017 and handed an 18-month suspended sentence. He was also handed a deportation order and ordered not to return to Switzerland for 10 years.
Winterthur has been considered a hotspot for Islamic radicalization in Switzerland with a number of young men having left the city to travel to Iraq and Syria to fight for the so-called Islamic State (ISIS).