Scots who own an airgun will need to be licensed under new laws passed by MSPs.
The Air Weapons and Licensing (Scotland) Bill also places tougher regulations on pubs, strip clubs, taxi firms and scrap dealers.
The new licensing regime for airguns fulfils a pledge by the SNP to regulate the weapons following the death of two-year old Andrew Morton, who was shot in the head in Glasgow in 2005.
Justice secretary Michael Matheson met with Andrew’s family before the debate.
Labour backed the Bill despite it being “far from ideal”, while the Tories and the Liberal Democrats said while they supported many parts of the legislation, they could not back measures relating to the licensing of air weapons, arguing the matter should have been addressed in a separate piece of legislation.
Mr Matheson said: “Our proposals have not always been universally welcomed but we believe they strike the right balance between respecting the interests of those people who shoot legitimately for work, sport, pest control or leisure, and the need to ensure that those who misuse guns do not have access to them.”
Mr Matheson said the legislation was not a ban on air weapons, but would prevent those who “deliberately and maliciously” target people, animals and property from accessing them.
The Bill also includes wider reform of licensing in Scotland, giving councils the power to reject applications for new pubs, off-licences, lap dancing clubs and private hire cars on the grounds that there are too many locally.
Labour’s Cara Hilton said her party backed the legislation because although it was “not without flaws”, it is a “step in the right direction”.
The Dunfermline MSP’s amendments to prevent 16-year-olds working as cleaners or in administrative roles in strip clubs were rejected.
Conservative MSP Alex Fergusson cited statistics showing that air weapon offences are at their second lowest level in the last decade, representing 0.06% of all reported crime in Scotland.
Lib Dem Liam McArthur said he had sympathy for the view the legislation was “two Bills masquerading as one”.