The SNP used its majority at Holyrood to pass the Offensive Behaviour at Football and Threatening Communications Bill, although ministers promised to review the use of the new powers.
Two offences will be created, targeting sectarian behaviour in and around football matches and on the internet. Those convicted could spend as long as five years in prison and be banned from stadiums.
It means police forces will be empowered to move against offensive behaviour at matches this season when the Act comes into force in the New Year.
But there was anger when a group of around 20 Celtic supporters who travelled to Holyrood under the banner "Fans Not Criminals" were furious after they were excluded from the public gallery for wearing campaign T-shirts.
Each bore a letter spelling out the combined message and they intended to stand up and turn round when a Bill to tackle religious hatred and bigotry related to football was passed, to spell out "SNP – Shame on You." But security staff told them this would not be permitted and they were only allowed to watch proceedings on a monitor in the committee room.
Jeanette Findlay, chairwoman of the Celtic Supporters' Trust, said they had come to protest against this "shockingly unnecessary Bill".
Opposition parties united to brand the Bill, which has won backing from police and prosecutors, a shambles and unworkable.
Labour, Conservatives, Liberal Democrats, Greens and Independent MSP Margo MacDonald issued a joint statement after the vote at Holyrood.
It read: "Members of all political parties are determined to wipe the blight of sectarianism from Scottish society. It is of real regret the first piece of legislation passed by this new Parliament has been railroaded through by the SNP.
"The SNP has used its majority to force through a bad law that risks doing more harm than good."
The only amendment to the legislation accepted by the SNP came from Patrick Harvie of the Greens, pledging the Government to consult with other parties as part of the review of how the new legislation would work in practice.