Scottish pupils will be offered less processed red meat and more fruit and vegetable in an effort to crack down on childhood obesity.
New regulations will see strict limits on the number of products like burgers and sausages children can eat a week.
Scotland will become the first part of the UK to set such a limit when the change is brought in by autumn 2020.
Fruit juices and smoothies will also be removed from primary and secondary schools in a bid to cut sugar intake.
The guidelines will require school kitchens to ensure a minimum of two full portions of vegetables and a full portion of fruit are offered as part of a school lunch.
It is part of a Scottish government drive to halve childhood obesity by 2030 after research revealed that 29% of children in Scotland are at risk of being overweight.
How will school meals change?
The guidelines differ between primary and secondary schools.
Younger children will not be offered any more than 175g of red or red processed meat at school mealtimes over the course of a week.
Of that, no more than 100g should be red processed meat such as bacon, ham or pepperoni.
In secondary schools, pupils will be offered no more than 230g of red meat - 130g of which can be processed.
According to NHS guidance on portion sizes, a quarter-pounder burger weighs about 78g and a slice of ham 23g.
Meanwhile, at least two portions of vegetables and one portion of fruit should form part of every school lunch in all schools.
In primary schools, a portion is 40g, in high schools, 80g.
Fruit and vegetables must also be available elsewhere in the school, for example in tuck shops.
Fruit juices and smoothies will be off the menu, as children are encouraged to drink water or milk. No added sugar and lower fat milk drinks such as flavoured and hot chocolate will be permitted.
Why are the changes being made?
Earlier this year First Minister Nicola Sturgeon said obesity and unhealthy eating was a "serious public health issue which cannot be ignored".
She set a new target to cut child obesity in Scotland by half by 2030.
At present, 29% of Scots youngsters are at risk of being overweight and 14% are at risk of being obese.
There are also increasing concerns about the links between processed meats and bowel cancer.
Announcing the new guidelines, Deputy First Minister John Swinney said school food and drink regulations introduced in 2008 needed updating.
"With more than 360,000 meals served a day, schools must follow the latest scientific and dietary advice and encourage young people to choose healthy habits for life," he said.
"Every school lunch will now contain more fruit and vegetables, and where food is served elsewhere in school full portions of fruit and vegetables must be on offer."
He added: "We have set maximum limits for consumption of red processed meat which is linked to an increased risk of cancer. This will also reduce exposure to harmful nitrites.
"And we know that one small carton of fruit juice or smoothie contains more than the entire recommended sugar intake for a primary pupil's lunch, so these drinks will no longer be served in schools.
"These changes will improve our school food, help tackle childhood obesity and give our children the best start in life."
What's the reaction to the new guidelines?
Claire Hislop, of NHS Health Scotland, said that the regulations will help to reduce health inequalities in Scotland.
Ms Hislop said:"We welcome the changes to the food and drink provided in schools, which will help create an environment in which children can choose a healthy, balanced diet.
"We know that health in Scotland is improving, but not for everyone. Supporting children and young people at school is an important way of addressing these inequalities.
"Together with a range of other actions to help support a healthy diet, this new guidance will contribute to improving health and reducing health inequalities in Scotland."
Steve Turner, of the Royal College of Paediatrics and Child Health, said the move sends out a "positive message" to children and parents.
"Obesity is an issue that has rippled through communities, not just in Scotland but right across the UK.," he said.
"It is contributing to rising numbers of children suffering with associated conditions like type two diabetes and breathing problems.
"We now need to see our neighbouring governments follow Scotland's lead by mirroring this move, but they can also go further.
"They must also protect children outside the school gates by banning the advertising of foods high in salt, sugar and fat on television and online before 21:00."