Some of the UK biggest retailers have signed up to a new crackdown on the sale of knives to under-18s after a Scottish schoolboy was fatally stabbed with a blade bought online.

In a deal completed just before Christmas Boots, B&Q, the Co-op and Aldi have all agreed to the new code, which includes tough age checks and extra training for staff.

It was the brainchild of the Prime Minister Theresa May when she was Home Secretary.

Ministers were prompted to act after Bailey Gwynne, a 16-year-old schoolboy in Aberdeen, died after he was attacked by a fellow pupil following a row about a biscuit.

His killer, also 16, who cannot be named for legal reasons, bought the knife from an online retail giant.

When questioned the boy told police that he had bought the knife on the net because "they don't check if you are 18".

He had avoided the need for a signature by leaving a note on his door saying that he was out and asking the delivery company to leave the package in a shed.

Under the code, drawn up by the Home Office, businesses agree to conduct tough age tests, regularly train staff about the issue and also package and displaying knives correctly.

When the crackdown was first announced last year the online retail giant Amazon and almost a dozen other companies committed to introducing robust security and age checks.

Welcoming the latest round of companies to sign up, Home Office minister Sarah Newton said: “Knife crime can have devastating consequences and we will act wherever necessary to reduce violence and keep our communities safe.

“It is very important that retailers have robust checks to prevent sales of knives to under 18s, both in stores and online, and I welcome the commitment from Aldi, B&Q, Boots UK and the Co-Op to help tackle this issue."

She added that the Conservative Government knew that there was more to be done on the issue and that they would continue to work with the police, retailers and voluntary groups.

Last year Scottish ministers welcomed the creation of the voluntary code of conduct, describing it as "extremely encouraging".

In Scotland it is illegal to sell knives or other products with blades or points to anyone under the age of 18.

However, cutlery and kitchen knives can be sold to those who are aged 16 and over.

Under the new code, enforcement is still a matter for Police Scotland.

Other companies who signed up in the first wave include Tesco, Lidl, Argos, Morrisons, Asda, Poundland, Sainsbury's, John Lewis and Waitrose.

The deal was agreed after Mrs May personally held a roundtable discussion with retailers.

At the time she said that knife crime had a “devastating” impact on victims, families and communities and that she was “determined” to do all that she could to prevent it.

Last night a Scottish Government spokesman said: "In Scotland it is already illegal to sell knives or similar products with blades or points to anyone under the age of 18 although it is legal to sell cutlery and kitchen knives to those aged 16 and over.

"We are studying the voluntary agreement with retailers announced by the Home Office closely to determine whether a similar scheme could add anything to existing legislation such as the licensing of knife dealers in Scotland."

Last year Bailey Gwynne's killer was locked up for nine years after a jury found him guilty of culpable homicide and carrying weapons.

Earlier this month it emerged that more than 440 dangerous weapons had been seized from schoolchildren across Scotland over the last 18 months.

And 200 pupils had been expelled for bringing weapons into school, making threats with them or using them on the premises.

Scottish ministers said that the penalties for carrying knives had been increased, including in relation to schools.