Children will be taught about healthy adult relationships from the age of four, with sex education made compulsory in all secondary schools, though faith schools will still be allowed to teach “in accordance with the tenets of their faith”, the government has announced.

Politicians and charities welcomed the radical overhaul of sex and relationship education but some secular campaigners expressed concern about the opt-outs that could be available for faith schools, saying the government needed to ensure some pupils were not left vulnerable.

STIs and crisp-packet contraception: what I learned from talking about sex in schools Read more

MPs across all parties had lobbied for the change, calling the previous guidance published in 2000 hopelessly inadequate for a modern world in which children can be exposed to pornography, online grooming and abuse at the touch of a button and at an increasingly young age.

In a written statement on Wednesday, the education secretary, Justine Greening, said existing statutory guidance made no mention of modern issues.

“The statutory guidance for sex and relationships education was introduced in 2000 and is becoming increasingly outdated,” she said. “It fails to address risks to children that have grown in prevalence over the last 17 years, including cyberbullying, ‘sexting’ and staying safe online.”

Sex education is compulsory only for secondary school pupils in local authority-run schools. Now all secondary schools, including academies, private schools and religious free schools, must make the age-appropriate sex and relationship education mandatory.

Parents will continue to have a right to withdraw their children from the lessons. Schools will have flexibility in how they deliver the subjects and they can develop an approach that is “sensitive to the needs of the local community” and religious beliefs.

Stephen Evans, the campaigns director of the National Secular Society, said: “This sounds like children from minority faith groups will be totally left behind by the government’s proposals. Under this approach, children who happen to be born into conservative religious groups will still be without proper sex and relationships education.”

The British Humanist Association said the announcement was a step in the right direction, but added that the government should ensure children in faith schools were not deprived of age-appropriate sex and relationships education.

The BHA’s chief executive, Andrew Copson, said: “A child’s access to accurate, evidence-based and relevant information, designed for the simple purpose of keeping them safe, should not be dependent on their religious or non-religious background, nor on the type of school to which they happen to have been sent. It should be clear to everyone that either all children have a right to this education, or no such right exists.”

The government will now make the change by tabling its own amendment to the children and social work bill, having previously been under pressure when more than two dozen Tory MPs signed their own backbench amendment to the bill, spearheaded by former women and equalities secretary Maria Miller.

Miller said the change showed the government had listened to “the overwhelming majority of parents and children” who were clear they wanted relationship and sex education to be a compulsory part of every child’s education.

David Burrowes, the Tory MP leading the reforms, said of the announcement: “It’s a victory for our cross-party, cross-interests coalition but above all it’s a victory for parents and children, and those vulnerable children who most need support to build healthy relationships.”

The Department for Education announcement was, said Cooper, “the right result for millions of children and teenagers who too often are exposed to things like bullying, sexting, revenge pornography or violence in teenage relationships and need support”.