Image caption Airgun owners will now have to license their weapons

MSPs have passed legislation requiring all airgun owners in Scotland to hold a licence.

The Scottish government pledged to introduce the licensing scheme following the death of Glasgow toddler Andrew Morton, who was shot dead by an airgun in 2005.

The Air Weapons and Licensing (Scotland) Bill also contains tougher regulations on pubs, strip bars, taxi firms and scrap dealers.

It was passed by 92 votes to 17.

Offences involving air weapons accounted for almost half of all offences involving a firearm in 2013/14, according to Scottish government figures.

The new law will mean anyone wanting to own an air gun will need to demonstrate they have a legitimate reason for doing so.

Sharon McMillan, the mother of Andrew Morton, was at the Scottish Parliament as MSPs debated the bill.

She told the BBC: "We are totally delighted that this day has finally come. We never thought it would come. It is a step in the right direction. I know it isn't an outright ban, but it is the next best thing to it.

"I would love to see the guns getting banned altogether, but I know that farmers and pest control need it for work.

"I just hope that they stick to their words and call it 'Andrew's Law', because that is what we are fighting for. We have a good future to look forward to, knowing that we have actually achieved something for him."

Image caption Andrew Morton was two years old when he was shot in the head by an airgun in 2005

Labour backed the bill despite describing it as "far from ideal", while the Conservatives 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 that the matter should have been addressed in a separate piece of legislation.

Justice Secretary Michael Matheson said: "We have a long standing commitment to reducing gun crime, and the licensing of air weapons has been central to that aim. It featured in our manifesto in 2007 and 2011, and the powers to regulate on air weapons were finally devolved to this Parliament in the Scotland Act of 2012.

"We have acted on this new power, consulting widely with experts and the public. 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."

The bill includes a wide reform of the licensing system in Scotland and will give councils the power to reject applications for new pubs, off-licences, lap dancing clubs and hire cars on the grounds that there are too many in the area.

It was endorsed by Holyrood's local government committee in March, but committee members called for action to close a "loophole" which could see strip clubs circumvent the new laws.

Premises which hold four or fewer sexual entertainment events a year would be exempt, but MSPs feared this could lead to strippers moving from venue to venue to avoid the law.

However, theatre productions that contain nudity will be exempt from the licensing shake-up.

Other provisions include a requirement for pub owners to prove that they are fit to run a premises, including disclosing spent convictions.

Councils must have the stated objective of reducing the consumption of alcohol when considering new licences while those who give alcohol to children to drink in public will be criminalised.

Communities will be given a greater say over the opening of lap-dancing bars while councils will also be able to judge whether there is an over-provision of private hire cars in the area.

The bill will also impose new regulations on scrap metal dealers to cut down on theft, including a requirement to get proper identification from those selling scrap and refuse payment in cash.

You can read through the debate on BBC Scotland's Democracy Live page.