In this Nov. 5, 2020 file photo, The Supreme Court is seen in Washington. (AP Photo/J. Scott Applewhite)

The US Supreme Court has upheld the law which aims to provide affordable health insurance for all Americans, dismissing a legal challenge from Texas and 17 other Republican-governed states.

This is the third time since 2010 that the Affordable Care Act (ACA), the signature policy of former president Barack Obama, has survived a challenge.

It bans insurers from denying coverage due to pre-existing conditions.

The law gave millions of low-income Americans access to medical insurance.

The justices ruled by a 7-2 majority that the challengers had no legal standing to file their case. The ruling did not touch on whether a key provision in the law was unconstitutional.

The legal challenge was backed by former president Donald Trump.

Under the act, millions of people in the United States must purchase health insurance or face a tax penalty.

But in 2017, Congress removed a key plank of the policy, eliminating the federal fine for those who did not sign up, known as the “individual mandate”.

The majority opinion was written by Stephen Breyer, the most senior liberal justice on the court.

He wrote: “The matter is not simply technical… It would threaten to grant unelected judges a general authority to conduct oversight of decisions of the elected branches of Government.”

Conservative Justice Samuel Alito dissented from the majority, along with one of Mr Trump’s appointees, Neil Gorsuch.

“No one can fail to be impressed by the lengths to which this Court has been willing to go to defend the ACA against all threats,” Mr Alito wrote.