Increased provision of free childcare is part of a package of reforms which have been approved by MSPs.

Increasing support for young people in care and the appointment of a "guardian" for every child in Scotland also form part of the bill.

The Children and Young People (Scotland) Bill was passed with 103 MSPs voting for it and with 15 abstentions.

The Scottish government said the bill aimed to "transform" services.

However, some of the proposals have been heavily criticised.

The bill will see an increase in free childcare for three, four and vulnerable two-year-olds, from 475 to 600 hours - around 16 hours per week - from August.

A bid from Labour to give vulnerable two-year-olds a legal right to care was defeated at the committee stage, as was a Tory proposal to guarantee that all children get two years of nursery care before school, regardless of when their birthday falls.

Research published by think tank Reform Scotland said the actual provision could vary by up to 317 hours, depending on the child's birth date.

Labour and the Liberal Democrats had also criticised the Scottish government for not increasing provision sooner.

Image copyright Kim Karam Image caption Protestors from the Scottish Kinship Alliance demonstrated against the kinship element of the bill outside the Scottish Parliament

A plan to extend help to young people in care would mean teenagers in residential, foster or kinship care would have the right to continue being looked after until the age of 21, with the Scottish government providing £5m a year until 2020.

Currently, affected young people remain in care until they are 19, but many leave earlier at the age of 16 or 17.

However, before the debate protestors from the Scottish Kinship Alliance demonstrated outside the Scottish Parliament, claiming support to young people would be reduced by the bill.

The change would give young people in care a "brighter future", according to Children's Minister Aileen Campbell.

Media playback is unsupported on your device Media caption Children's Minister Aileen Campbell, pictured with Education Secretary Mike Russell, said the bill would transform family services in Scotland

The bill will also extend free school meals to all children in the first three years of primary school, from January 2015.

Meanwhile, the plan to appoint a so-called guardian for every Scottish child has been opposed by some religious groups and the Conservatives.

The proposal to appoint specific named persons from the NHS and councils to monitor every young person's well-being from birth to 18 is considered one of the most controversial aspects of the bill.

Some religious groups, including the Church of Scotland, said the bill raised concerns about diminishing the position of parents and increasing the role of the state in modern society.

The Christian Institute, a campaign group which promotes family life and a literal interpretation of the bible, has said it will lodge a court action against the plan.

Conservative education spokeswoman Liz Smith tabled a last-minute amendments on the plan that would have limited the named person to under-16s, rather than under-18s. The move was defeated.

Ms Campbell insisted appointing a named person - such as a health visitor, midwife or teacher - for every child would "provide a safety net for those who need one".