Prince William has said he would "fully support" his children if they were gay, but admitted he would "worry" about the added pressures they would face.
It was something he had thought about since becoming a parent, he said.
"I wish we lived in a world where it's really normal and cool, but particularly for my family, and the position that we are in, that's the bit I am nervous about," he said.
The duke was speaking to young people at a LGBT youth charity in London.
The Albert Kennedy Trust (AKT) supports LGBT young people who are at risk of homelessness.
The duke said he backed "whatever decisions" his children made, but added: "It does worry me from a parent point of view.
"How many barriers you know, hateful words, persecution, all that and discrimination that might come, that's the bit that really troubles me.
"But that's for all of us to try and help correct and make sure we can put that to the past and not come back to that sort of stuff."
By Ben Hunte, BBC News LGBT Correspondent
This is a huge moment for LGBT people around the world.
For a member of the British Royal Family to give such an endorsement to lesbian, gay, bisexual and transgender rights, and their fight for equality, is a big deal, especially in a time when the visibility of LGBT people is being continually questioned.
However, with the Duke of Cambridge being a figurehead for the Royal Family as well as the Commonwealth, it is also worth remembering that homosexual activity is still a criminal offence in 35 of the 53 Commonwealth nations - and it is only legal in 18.
Many will now be wondering whether Prince William's words could have a positive impact on these places, where people are still fighting for their lives because of who they love.
Prince William and the Duchess of Cambridge have three children - five-year-old Prince George, Princess Charlotte, four, and one-year-old Prince Louis.
The duke said this was not the first time he has been asked this hypothetical question about his children.
The Queen's cousin, Lord Ivar Mountbatten, and his partner James Coyle were the first royal same-sex couple to get married last year.
The duke said parents often ask his views on the issue and that because of this, he and the Duchess of Cambridge have "been doing a lot of talking" to make sure their children are "prepared".
He also expressed his shock at a recent attack on Melania Geymonat and her partner Chris on a London bus, saying: "I was really appalled".
Tim Sigsworth, chief executive of AKT, said the duke's comments would make a "massive difference" and sent "a message that we need to support, and we need to empower LGBT people".
He said: "I was personally rejected by my mum, and the idea that the future monarch is saying they would support their children if they came out as LGBT is a message to the whole of society really, a message that we need to support and we need to empower LGBT people."
During a conversation with AKT's founder, Cath Hall, William also spoke of his concerns about the pressures on LGBT young people coming out to their family and friends.
"It's a real pressure to live under," he said.
"I've been looking into issues around suicide and I imagine that the figures in the LGBT community are high, because of all the barriers and stigma around acceptance."
Many people have praised the prince for the comments.
Charity Mermaids UK, which supports gender diverse and transgender children, said it "loves that Prince William supports LGBTQ children".