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

In a historic 5-4 decision, Justice Anthony Kennedy writing for the majority 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.

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

Before the ruling on Thursday, gay couples could marry in 37 states in addition to Washington DC.

Loud cheers erupted outside the court after the ruling was announced where scores of people camped out for hours awaiting news on Friday.

One of the demonstrators, Jordan Monaghan, called his mother from his mobile phone amid the celebrations.

"Hey mom, I'm at the Supreme Court. Your son can have a husband now," Mr Monaghan said.