Barack Obama tweets #lovewins as gay marriage is legalised in all US states

Gay rights supporters celebrate after the US Supreme Court ruled that the U.S. Constitution provides same-sex couples the right to marry

The US Supreme Court has ruled that same-sex marriage is a legal across the United States.

In a historic 5-4 decision, Justice Anthony Kennedy ruled that marriage is a constitutional right for all.

"No union is more profound than marriage," he wrote, backed by the court's four more liberal justices.

He added while the ruling recognises a centuries-old "understanding" of marriage as "a union between two persons of the opposite sex," he said "the history of marriage is one of both continuity and change."

"That institution, even as confined to opposite-sex relations, has evolved over time."

President Barack Obama said the decision was a "big step" toward equality.

Writing on Twitter, he said: "Today is a big step in our march toward equality. Gay and lesbian couples now have the right to marry, just like anyone else. #LoveWins."

It is unclear how quickly marriage licences will be issued in states where gay unions were previously banned.

Before the ruling, same sex couples could marry in 37 states in addition to Washington DC.

Gay rights supporters took to the streets to celebrate the decision outside the court after the ruling was announced.

Hundreds of people had camped out the night before awaiting the landmark decision.

The case behind the ruling began in 2013, after the Supreme Court ruled in a separate matter that same-sex spouses must be afforded the same federal benefits as other married couples.

That ruling however did not tackle the whether gay marriage is a Constitutional right.

Gay supporter Jon Dawson, 45, said: "We have waited for this day for decades.

"For too long America has let its prejudices rule.

"It doesn't matter what sex you are if two people love each other.

"It is a great day in American history and long overdue."

However, many Christian conservatives attacked the ruling.

"We must resist and reject judicial tyranny, not retreat," said Mike Huckabee, Republican presidential candidate and former Arkansas governor.

"The only outcome worse than this flawed, failed decision would be for the president and congress, two co-equal branches of government, to surrender in the face of this out-of-control act of unconstitutional, judicial tyranny."