Douglas Cruikshank, 39, and 18-year-old Chelsea Lambie threw bacon at the window of Edinburgh's Central Mosque and wrapped the meat around door handles on January 31 last year.
Edinburgh Sheriff Court heard they and a third offender were associated with the Scottish Defence League, prosecutors said.
Wayne Stilwel, 25, from Gorebridge, Midlothian, previously admitted his involvement and was sentenced to 10 months in September.
Cruikshank, from Galashiels in the Borders, and Lambie, from Paisley, Renfrewshire, were convicted of threatening and abusive behaviour following a trial.
Cruikshank was today sentenced to nine months' imprisonment and Lambie was ordered to spend 12 months in a Young Offender Institution, the Crown Office said.
The trial heard that a man who was inside the mosque praying on the morning of the attack heard something hitting the prayer room window. Slices of uncooked bacon were later discovered stuck to the window. Islam prohibits the consumption of pork.
John Logue, procurator fiscal for the east of Scotland, said: "The Muslim community are a valued and integral part of Scottish society and there is no place for such attacks in modern Scotland.
"As we strive to become a fairer and more tolerant society to live in we will not let it be blighted by a narrow minded and hateful minority.
"Prejudice and bigotry have a corrosive effect on our nation and we will maintain our zero-tolerance approach towards such crimes which will continue to be investigated carefully and prosecuted robustly."