The legal action was filed by Greenpeace and other environmental organisations, which claimed that the plan approved by the government did not do enough to tackle climate change.
The court said it had decided that Madrid's plan is not arbitrary, and is in line with the law and the climate commitments taken by the European Union.
In a draft update of its climate and energy plan, the Spanish government has proposed an increase in its 2030 emission reduction target. It proposed to cut emissions of climate-warming gases by 32% from 1990 levels, up from the current target of 23%.
In their lawsuit, green groups called for a 55% reduction target.
The court argues that Spain's decision to align itself with the European Union's efforts can not be deemed as "arbitrary."
"Obviously, we can only disagree with the Supreme Court," Greenpeace's Ines Diez said, adding that the ruling can be appealed in the constitutional court.
The ruling came the same day as the United Nations Environment Programme and the Sabin Center for Climate Change Law at Columbia University released a report on climate change litigation.
The total number of climate change cases rose from 884 in 2017 to 2,180 in 2022, according to the report.
(Reporting by Pietro Lombardi, editing by Inti Landauro and Sharon Singleton)
By Pietro Lombardi