The decision is a victory for Hollywood and companies such as Disney and AOL Time Warner who stood to lose millions of dollars worth of archives to the public domain.
Internet publisher Eric Eldred had argued that a recent change to the law - extending the copyright ownership of old songs, books and cartoon characters - was unconstitutional.
"
(The ruling) ensures copyright owners the proper incentive to originate creative works for the public to enjoy
"
Michele Bergman
Disney
But the court's 7-2 ruling gives Congress permission to repeatedly extend copyright protection.
It means internet publishers and others will not be able to make old books available online and use the likenesses of Mickey Mouse and other old creations without paying royalties.
Justice Ruth Bader Ginsburg said: "History reveals an unbroken congressional practice of granting to authors of works with existing copyrights the benefit of term extensions so that all under copyright protection will be governed evenhandedly under the same regime."
Public harm
Justices said the copyright extension, named after the late Congressman Sonny Bono of California, was neither unconstitutional overreaching by Congress nor a violation of free-speech rights.
In 1998, Congress extended by 20 years copyright protection, which until then had been granted for 70 years after the death of the author.
For anonymous works or those owned by companies, the law made the new limit 95 years.
Justices John Paul Stevens and Stephen Breyer opposed the ruling, saying the court was making a mistake.
Justice Breyer said: "The serious public harm and the virtually non existent public benefit could not be more clear.
"Copyright holders stand to collect about $400m more a year from older creations under the extension."
Good incentive
Justice Stevens said the court was "failing to protect the public interest in free access to the products of inventive and artistic genius".
Had the ruling gone the other way copyrights for movies such as Casablanca, The Wizard of Oz and Gone With the Wind could have been threatened.
Protection for the version of Mickey Mouse portrayed in Disney's earliest films, such as 1928's Steamboat Willie was also due to expire.
The ruling affect small music publishers, orchestras and church choirs who must pay royalties to perform some pieces.
A Disney spokeswoman Michele Bergman said the ruling "ensures copyright owners the proper incentive to originate creative works for the public to enjoy".