
Guarda costa or guardacosta ("coast guard") were privateers active in Spanish America between the 17th and 19th centuries who operated against pirates, smugglers and foreign warships and privateers. Established by Spanish colonial authorities in the 17th century, their prominence and importance increased in the 18th century following naval reforms designed to address the increase in piracy and smuggling in Spanish America, in particular British merchants who smuggled goods to Spain's West Indian and South American colonies under the cover of the South Sea Company's hold on the Asiento de Negros. These reforms resulted in greater collaboration between guarda costas and the Spanish Navy, promoters by commanders like Blas de Lezo.
Guarda costas detained and seized foreign vessels accused of piracy, smuggling or otherwise operating against Spanish interests. Though they served as a key plank in Spanish America's maritime defence and contributed to colonial economies with goods sold from the vessels they seized, guarda costas became infamous throughout Europe and its colonies for indiscriminately targeting foreign ships and mistreating their crews; one such seizure sparked the War of Jenkins' Ear with Britain. Due to lax oversight, crews of guarda costas were often involved in smuggling and piracy. Guarda costas ceased to exist following the Spanish American wars of independence in the early 19th century.

Guarda costa were eminently recruited from local populations. They supplied their own ships and were conferred authority to capture and bring to port every ship suspected of piracy or contraband they came upon, receiving part of the prize in exchange. Although the captured ship's owners had the right to reclaim their ships and goods, those were usually sold quickly and their owners were typically redirected to buy them or to travel to Madrid to complain. The arrested crews were often subjected to torture and sentenced to prison, death or penal labour.

The nature of their job conceded them ample autonomy in the interpretation of the laws and frontiers, meaning that in practice guarda-costa took what they wanted with little to no evidence of crime. The mere fact of finding cargo produced in the Hispanic Indies, like cocoa, salt, hide, snuff and logwood, or even a single real de a ocho, sufficed to declare the ship captured for piracy or smuggling. Guarda costas routinely killed entire crews, and in their greatest extralimitations they assaulted settlements in English, Dutch and Danish territories.
They commonly used half-galleys of two masts and up to 120 men named periagua, which were hidden inland with vegetation by day and deployed in night attacks against unaware vessels. Over time they adopted many kinds of ships, big and small, like the quick balandra or sloops of up to 25 men, which were gathered in small numbers to board enemy ships. Although their small, relatively lightly armed vessels were no match for the foreign ships of the line sent in to hunt them down, they were extremely difficult to find and catch. Guarda costa often teamed up with small royal fleets called armadillas (armadillo was also used for a single, well-armed ship).
Their crews were as ethnically diverse as the Spanish Main itself, being composed mostly of mestizo, mulatto, indigenous, black and peninsular members. Governor of Jamaica Sir Thomas Leech described them as "a mongrel parcel of thieves and rogues". Some also came from Italy, the Balkans, and renegades of all nations who had pledged loyalty to Spain. The success of the guarda costa drove pirates and buccaneers to change sides and join them, sometimes in exchange for amnesty. The imperial administration accepted them with remarkable liberality, although favoring Catholics or those willing to convert. Crewmen hailing from Biscay were the most prestigious corsairs.
In 1674, after the greater part of two centuries refusing to authorize privateering in the Caribbean on any meaningful scale, the Spanish crown under Charles II of Spain started issuing letters of marque to protect its coastal settlements. Henry Morgan's defeat of the Armada de Barlovento during his raid on Lake Maracaibo in 1669 was a factor in the decision. Charles II of Spain went to the extent of owning a ship himself, crewed by renowned Basque corsairs, to encourage private enterprise. The measure met considerable success, with over 200 Spanish privateering vessels being commissioned in the Iberian Peninsula alone. The first fleets in the Indies were composed of royal ships, but the high cost of maintaining them led to their intermixing with private vessels, recruited locally as auxiliars. Guarda costas, often coastal militiamen and amnestied pirates, soon became the biggest threat to pirates and buccaneers in the Caribbean.
Throughout the 18th century, the privateer guarda costas were the main Spanish imperial defensive measure against piracy, especially due to constant involvement in European wars which drained Spanish naval resources. Great Britain earned trading rights with the 1713 Peace of Utrecht, but their enforcement was mainly carried on by the guarda costas, who acted harshly to suppress illegal trade. International tensions rose as the British routinely accused the Spanish of disrupting their legal merchant traffic, while in turn the Spanish accused the British of disrespecting the treaty conditions. The number of privateers swelled after the War of the Quadruple Alliance.
While guarda costas could be based almost anywhere, their favored haunts were the Cuban ports of Santiago and Trinidad, but after 1720 they also spread to St. Augustine in Florida and Puerto Rico. The last became important enough to be nicknamed the "Dunkirk of America" due to its privateering activity being comparable to that of the notorious Dunkirkers of Habsburg Spain. The Guipuzcoan Company of Caracas, founded in 1728, also received permission to hire privateers. The number and aggression of guarda costa increased during the political tensions of 1729, helped by the hand of José Patiño, a promoter of privateering who oversaw similar activities against Barbary pirates in the Mediterranean.
One of the main promoters of the guarda costa system was commander Blas de Lezo, who helped governor Pedro José Fidalgo to found the official Company of Privateering of Cartagena de Indias en 1737. In 1740, the Cuban authorities founded the Royal Company of La Habana, which enjoyed license to field guarda costa. Among their backers were paradoxically local Hispanic elites who thrived off smuggling, as they engaged in privateers in order to destroy their foreign competition. Another of their usual targets was the British colony of Jamaica, where they raided the coastal shipping and the transport of produce from their plantations.

These clashes led to incidents such as the one that triggered the War of Jenkins' Ear, named after a British captain who reportedly lost an ear at the hands of a coast guard. In this conflict, the coast guards of the Guipuzcoan Company effectively functioned as military and transport units. The Fort of San Agustín, which had been highly active since 1738, was one of their bases; its governor Manuel de Montiano issued numerous letters of marque to Cubans, residents of New Spain and others, including the famous British-escaped slave Francisco Menéndez. During the war, these coast guards supplied the city by seizing British merchant vessels, and their raids on English coastal towns reached as far as South Carolina and Delaware, where the local patrols established in response proved largely ineffective.
Zenón de Somodevilla, Marquis of La Ensenada became a driving force behind guarda costas after his arrival in the royal council in 1743, preceding Julián de Arriaga y Ribera. During the latter part of the War of Jenkins' Ear, between 1743 and 1747, the guarda costa captured almost 200 British merchant ships.
In the 1770s, increasing centralization of Spanish imperial power started reducing the private enterprise aspect of guarda costa activity, which was increasingly funded by the royal treasury under the Derecho de Armada y Piragua. The authorities further attempted to increase the appearance of law enforcement rather than privateering, which led to a brief controversy between José de Mazarredo and Francisco Machado over whether captured ships should be labelled as prey or confiscation. In 1788, the privateer based guarda costa system transitioned into a fully state financed and directed coast guard under the government of Manuel Godoy, with the Instrucción being issued in 1803.