The government announced today that sex education will become compulsory for all schools, including lessons on gay relationships and sexually transmitted infections such as HIV.

Teaching will begin from the age of five. Primary school children will learn about their bodies and puberty, along with marriages, divorces and civil partnerships.

Pupils in secondary education will be taught about contraception, gay and lesbian relationships and HIV, as well as the emotional implications of having sex.

However, faith schools will be allowed to teach sex education in line with their own ethos or beliefs. They are required to educate pupils about issues such as abortion and the tolerance of homosexuality but may present them in congruity with religious teachings.

One-third of schools in England are faith schools and the plans suggest that pupils could be taught about same-sex relationships while learning that they are against their religion.

Currently, parents are allowed to withdraw children from sex education lesson up to the age of 19. This will now change to 15 to ensure that pupils have at least one year of sex education before they reach the age of consent.

Ed Balls, the schools secretary, said: “You can teach the promotion of marriage, you can teach that you shouldn’t have sex outside of marriage, what you can’t do is deny young people information about contraception outside of marriage.

“The same arises in homosexuality. Some faiths have a view about what in religious terms is right and wrong – what they can’t do though is not teach the importance of tolerance.”

The announcement follows a review of sex education by Sir Alasdair Macdonald, headteacher of Morpeth School in east London.

The National AIDS Trust has welcome the plans, saying that all young people have a right to information about sexual issues.

Chief executive Deborah Jack said: “We are pleased that discussion of same sex relationships and HIV is included in the PSHE education programme of study. HIV is a serious long-term condition and young gay men remain the group of young people most at risk. In the past young gay men have often been ignored in sex and relationships lessons in schools and the result has been a rise in young gay men being diagnosed with HIV.”