Let's say it's the golden age of piracy in the Caribbean. A warship of some great nation found a smaller pirate vessel on the high seas, attacked and captured it. On board, there are some pirates left alive and a rich haul from their robbery. Would the winner try to find out who these goods belonged to, to return them to the rightful owner? If the winner was, say, British, and the owner was Spanish, and both nations were hostile to each other at the moment, would the winner just take the loot? Did the captain have an obligation to give it all to the Crown?
It depends on each nation's legislation, but in the case of Spain, or Castile for that matter, legislation was more than abundantly clear since the XIII century, when king Alfonso X the Wise compiled the Siete Partidas, a great corpus of laws, civil, criminal, administrative, etc. These Siete Partidas, of course, contain legal aspects on piracy and on what would happen with the bounty captured from a pirate. Partida II, Title XXVI, law XXXI, gives us this:
As the ancients from Spain considered it good that when some people stole from those who safely brought some things by sea, to the King's land, or took it somewhere else that was not enemy's land, whatever was taken this way, be it returned to its first owners. Outside of this, had the enemies taken it and put it safely away, and was taken from them after it by force, then shall it be theirs, unless they were salaried, in which case shall it be divided as afore mentioned.
As we see, the Spanish laws heavily took from Roman law, passing of course through Visigothic law (vide Forum Judicum), so there are many concepts affected like firm possession and actions in itinere. As the language is rather confusing, no less confusing was it for me checking the legislation, as it is written in XIII century Castilian, specifically Castilian from Toledo, I will explain a bit what that paragraph means.
If the bounty captured from pirates or enemies was recovered before they had taken it to a safe place, which means before they had gained possession (not property) of the things, then the loot captured had to be returned to its rightful owners. If the enemies or pirates had gained possession, then the recoverers kept what they had recovered, legally gaining possession of the things.
This laws from the XIII century do sound ancient, but they were the legal corpus of Castile on many matters, except where laws or provisions contained within were substituted by new legislation, which means that some points of the Partidas were part of the Spanish legislation until 1889 when the Civil Code was approved. This particular law was made more clear with Philip II's Royal Decree of may 29th 1584, present in the Cedulario Indiano, which means it was a law in vigour in the Indies. I'll translate the relevant part:
Whenever you may capture loot from a corsair or enemy, if there were any properties, of whichever nature, that they had stolen from subjects and vassals of mine, you shall give and consign them in full in the same state you found them to whosoever their rightful owners were, at once without delay or setting any impediment.
So, long story short, the captain was under the legal obligation to give whatever he took from pirates to its rightful owners, if they were known. If the loot could not be identified, then, the recoverers would take it for themselves. Would the winner actually try to find who the rightful owners were? Not really. The only case where they would actually take time and effort to return the loot would be if they captured an enemy ship that contained the Quinto Real (the King's fifth), insofar as not returning it would in itself constitute an act of theft against the Royal Treasury, which would be punishable by death. The Quinto Real, or Royal Fifth was easily identifiable, as it was transported in the form of ingots marked with the stamp of the mint and the King's coat of arms.
Sources:
Cruz Barney, Oscar (1999), El combate a la piratería en las Indias (1555-1700). Mexico and Oxford: Universidad Iberoamericana and Oxford University Press.
López, Gregorio (1555), Las Siete Partidas del sabio rey don Alonso el nono, nuevamente glosadas por el licenciado Gregorio López. Salamanca: Andrea de Portonaris. Facsimile by Biblioteca Jurídica de la Agencia del Boletín Oficial del Estado (Madrid, 2011). Digitised here
García Gallo, Alfonso, editor (1945), Cedulario Indiano recopilado por Diego de Encinas. Madrid: Ediciones Cultura Hispánica. Facsimile by Biblioteca Jurídica de la Agencia del Boletín Oficial del Estado (Madrid, 2018). Digitised here