Barack Obama has explained that seeing his own daughters grow up in a world where gay people are automatically accepted gives him “hope” for the future.

The President was speaking to YouTube star Ingrid Nilsen, as part of an annual White House tradition started by Obama of reaching out to the site’s young audience.

Nilsen, who came out as a lesbian last year, asked the President about the case of Alabama’s Chief Justice, who is trying to halt same-sex marriage in the state.

The President promised her of equal marriage: “It’s here to stay”.

He said: “I understand that the Supreme Court has ruled that under the constitution, everybody in all 50 states has the right to marry the person they love. That’s now the law of the land.

“The fact that an Alabama judge is resisting… is just a temporary gesture by this judge, which will be rapidly overturned.

“It violates the supremacy clause – when the Constitution speaks, everybody has to abide by it, and state judges can’t overturn it.”

He added: “You shouldn’t be worried about that… I think that the process of changing people’s attitudes, of people treating the LGBT community with full equality and respect, making sure they’re not discriminated against on the job or in housing – those are the areas we’ve still got some significant work to do.

“For young people, making sure they’re not bullied, that requires the participation of all of us.

He added: “We’re not there yet – but on the other hand, I’ve got to tell you… to watch the amazing strides that we’ve made over the past five years, ten years, all as a result of people who had the courage to come out and say ‘here’s who I am’, but who did it 20-30 years ago when it was incredibly tough.”

He continued: “The thing that makes me most hopeful is when I talk to [daughters] Malia and Sasha, young people of your generation – their attitudes are so different.

“The notion that you’d discriminate against someone because of sexual orientation is so out of sync with how most young people think – including young Republicans, young Democrats – it’s across some of the usual political lines.

“This is an issue that is going to be moving in the right direction as long as we stay vigilant and keep working on it.”

It was the last time Obama will take part in the annual tradition – as he will leave office in January 2017.

Obama did not reference his potential successors in the interview.

Six of the Republican candidates have pledged to pass a law permitting discrimination against married gay people, while others say they will attempt to roll back same-sex marriage altogether.

Both major Democratic candidates, Hillary Clinton and Bernie Sanders, have pledged their full support to continuing Obama’s LGBT rights legacy.

Watch the interview below: