Sex and relationships education is to be made compulsory in all schools in England, the government has announced.
All children from the age of four will be taught about safe and healthy relationships, Education Secretary Justine Greening said.
Children will also be taught, at an appropriate age, about sex. But parents will still have the right to withdraw their children from these classes.
Until now, sex education has been compulsory only in council-run schools.
Since academies and free schools are not under local authority control, they do not have to follow the national curriculum and have not been obliged to teach sex and relationships education (SRE).
Current guidance 'outdated'
In practice, the vast majority do teach the subject - the government's announcement will mean all schools across the system will be bound by the same obligation.
Age-appropriate lessons will have particular emphasis on what constitutes healthy relationships, as well as the dangers of sexting, online pornography and sexual harassment.
In primary schools, the focus would be on building healthy relationships and staying safe, the Department for Education (DfE) said, while in secondary school it would focus on sex as well as relationships.
The government will hold discussions on what should be taught to children, and at what age, and there will be a public consultation later this year.
Pupils could be taught the new curriculum from September 2019, the DfE said.
In an interview with the BBC, Ms Greening said: "At the moment, many schools teach sex and relationships education.
"But it's not mandatory, and, therefore, for many children, they are not coming out of our schools really being equipped to deal with the modern world or indeed be safe and protected from some of the very modern challenges that young people face on cyberbullying and sexting.
"What we're introducing today is mandatory relationships and sex education in all secondary schools, but also mandatory relationships education in primary schools as well.
"And, of course, all of this, it's important, is age-appropriate and, of course, it's also important to retain, for sex education, a parent's right to withdraw their child."
Ms Greening said schools would have flexibility over how they delivered the subjects and faith schools would continue to be able to teach in accordance with the tenets of their faith.
The current guidance for SRE, introduced in 2000, was outdated, she added.
'Sexual health time bomb'
The news was welcomed by the Local Government Association, which has been campaigning for compulsory sex education in all schools.
Izzi Seccombe, chairman of the association's community wellbeing board, said: "The lack of compulsory SRE in secondary academies and free schools is storing up problems for later on in life, creating a ticking sexual health time bomb, as we are seeing in those who have recently left school.
"We believe that making SRE compulsory in all secondary schools, not just council-maintained ones, could make a real difference in reversing this trend, by preparing pupils for adulthood and enabling them to better take care of themselves and future partners."
But critics fear the announcement weakens the influence of parents.
The organisation Christian Concern said it was not for the state to prescribe what was taught in this area.
Chief executive Andrea Williams told the BBC: "Children need to be protected, and certainly when they're [still at primary school], we need to be guarding their innocence.
"We need to be protecting them from things, working with parents to ensure that what they might need to know - which will be different for every child child, different in every context across the country - is properly looked at.
"But this is something that should be individualised, not something that the state can deliver wholesale."
Safe at School Campaign, run by the Society for the Protection of Unborn Children, described the announcement as a "tragedy".
National co-ordinator Antonia Tully said: "Parents will be absolutely powerless to protect their children from presentations of sexual activity, which we know is part of many sex education teaching resources for primary school children.
"The state simply cannot safeguard children in the same way that parents can. This proposal is sending a huge message to parents that they are unfit to teach their own children about sex."
School leaders, however, welcomed the news.
Russell Hobby, general secretary of school leaders' union NAHT, said: "It is so important for young people to be taught about appropriate relationships, and the duties set out today bring that one step closer."
Malcolm Trobe, interim general secretary of the Association of School and College Leaders, said: "We do not believe it is necessary for the government to provide standardised frameworks or programmes of study, and we would urge ministers against being too prescriptive," he said.
Jonathan Baggaley, chief executive of the PHSE Association said: "This is a historic step and a clear statement of intent from government.
"Following years of campaigning we are delighted that Justine Greening has taken this vital step to respond to the clear call from parents, teachers and young people that education must prepare all children, in all schools, for the opportunities and challenges of modern life."
Ms Greening's announcement follows a widespread campaign by charities, MPs and local authorities, calling for (SRE) to be made a statutory for all schools.
At the end of last year, the chairmen and women of five different Commons select committees called on Ms Greening to make SRE a statutory subject.
Elsewhere in the UK
SRE is part of the curriculum in Wales, but it is not currently compulsory.
The Welsh government says it expects young people to receive age-appropriate lessons in school, covering "all aspects of relationships, sexual health and wellbeing issues".
The subject is not compulsory in Scotland but new guidance was introduced in 2014. Schools and local authorities are responsible for deciding how to put the guidelines into practice.
In Northern Ireland, the Department of Education requires each school to have its own written policy on how it will address the delivery of relationship and sexuality education (RSE).
RSE must be delivered "in a sensitive manner which is appropriate to the age and understanding of pupils and the ethos of the school".