The government will require schools in England to take "the religious background of all pupils into account" during lessons about relationships and sex when they become compulsory next year.

In newly-published final guidance the Department for Education (DfE) has also said faith schools will have licence to teach "the distinctive faith perspective" on relationships.

Schools will also be given licence to decide how to ensure their teaching is "sensitive and age appropriate" and conduct "balanced debate" on "issues that are seen as contentious".

The guidance will require teaching in all schools to reflect equality law and says the DfE expects "all pupils to have been taught LGBT content at a timely point".

In accompanying comments the education secretary Damian Hinds said he "would strongly encourage schools to discuss with children in class that there are all sorts of different, strong and loving families, including families with same-sex parents, while they are at primary school".

In April the National Secular Society wrote to Hinds to urge him to reconsider the requirement to take pupils' "religious background" into account when teaching about relationships. The NSS's letter came amid an escalating religious campaign against LGBT-inclusive teaching.

Earlier this month the NSS highlighted a plan by ultra-Orthodox Jewish schools to avoid teaching about same-sex relationships by exploiting loopholes in DfE regulations.

The new guidance outlines expectations which will apply to schools when compulsory education about relationships, sex and health is extended to all schools in England from September 2020.

Relationships education will be required in primary schools, with relationships and sex education (RSE) compulsory in all secondary schools and a new subject of health education compulsory in all state-funded schools.

The guidance gives parents the "right to request that their child be withdrawn" from "some or all" of sex education delivered in secondary schools as part of the RSE curriculum. This is in line with the government's draft guidance in February, when it resisted pressure from religious groups to extend parents' right to withdraw their children.

There remains no right to withdraw children from relationships education and there will be no right to withdraw from the new subject of health education.

There will be an automatic right to withdraw children from sex education delivered at primary school, other than in relevant sections of the science curriculum.

NSS chief executive Stephen Evans said the guidance represented "a step forward" but left "too much wiggle room for faith groups".

"The introduction of compulsory education on relationships, sex and health in all schools is a significant decision which will benefit children, women, LGBT people and wider society. But as so often, religion is the elephant in the room and the government has been too reluctant to confront it.

"Requiring schools to take children's 'religious background' into account creates an unreasonable expectation that faith-based opposition to teaching about healthy relationships may be accommodated. This requirement should be removed to send a message that religious groups do not have a veto on education which is reasonably judged to be in the best interests of children and society.

"Giving faith schools licence to teach from a faith perspective is also a misguided decision. Our research has shown that religious groups intend to exploit loopholes in government guidance and undermine the rights of children to receive an education which prepares them for the world they will encounter."

In February the NSS highlighted the messages being promoted by Kate Godfrey-Faussett, a prominent member of the primarily Islamic-based group Stop RSE who secured a debate in parliament on the subject. The NSS found that she had encouraged Muslims to adopt a "psychological" or "mental health" response to same-sex attraction.

Last year the NSS also found that three-quarters of England's state-funded secondary faith schools were distorting education about sex and relationships by teaching about them through a religious lens. The society's Unsafe Sex Education report warned of the risks of allowing faith schools to teach about the topics through the tenets of their faith.

The guidance was published as MPs debated parents' involvement in teaching in the House of Commons on Tuesday. The debate was brought by Labour MP Roger Godsiff, who represents the Hall Green area of Birmingham and has expressed support for protesters who have opposed LGBT-inclusive teaching at schools in the city.

During the debate the minister for school standards Nick Gibb said schools should "consider whether aspects of their curriculum may be sensitive to the parents of their particular cohort" and "ensure that they have properly engaged them on this content".

Gibb also said "some people on both sides of the debate" were "exploiting the situation due to their own lack of tolerance for the other side".

NSS honorary associate and Labour MP Angela Eagle asked Gibb if he had given "almost an open invitation to these organisations that are already spreading disruption across the country to do even more of it".

Elsewhere in the debate Eagle made a heartfelt intervention, in which she said LGBT people "are not going to get back in the closet, or hide, or be ashamed of the way we are". She urged MPs to resist "this view that if somebody has a religious objection somehow there can be no debate about it".

Labour MP Stephen Doughty brought up Godfrey-Faussett's claim, reported by the NSS in February, that making RSE compulsory was part of a "totalitarian endeavour to indoctrinate our children in secular ideologies".

He also highlighted the fact that a group called Islamic RSE was making "wild and fanciful allegations" and encouraging parents to "infiltrate governing bodies or parent teacher associations". Last month NSS research revealed that Islamic RSE was promoting anti-LGBT, anti-sex and anti-contraceptive messages and encouraging sympathetic parents to get involved in school governance.

During the debate Godsiff claimed the "controversies" in Birmingham "could have been avoided" if schools had approached equality teaching "in different ways" and "taken the parents' concerns into account".

Several other MPs, including NSS honorary associate Lloyd Russell-Moyle of Labour, disagreed with him.

NSS honorary associate Tom Brake also asked what the government could do to "counter what appears to be an organised campaign".

Discuss on Facebook