BBC reported Thursday that Odyssey Marine Exploration must return more than half a million gold and silver coins to Madrid, which argued the treasure found in the Atlantic Ocean was part of the country's national heritage.
The company says it plans to appeal the ruling, the British network reported.
The ship's haul was brought ashore in Gibraltar and then flown to Miami. The Spanish government said the wreck was that of the Mercedes, a naval frigate destroyed by the British in 1804.
Spanish Culture Minister Angeles Gonzalez-Sinde praised the ruling.
"It's a very positive decision for the Spanish government and for all the Spanish citizens because it guarantees that this ship and the remains of this ship will come back to Spain, which was originally the owner of this ship," he told the network.