The Kingdom of Spain and the United States of America maintain bilateral international relations. The Spaniards were the first Europeans to establish a permanent settlement in what is now United States territory. The first settlement in modern-day United States territory was San Juan, Puerto Rico, founded in 1521 by Spanish explorer Juan Ponce de León. 35 years later, Spanish admiral Pedro Menéndez de Avilés founded the city of St. Augustine, Spanish Florida (the earliest settlement in the continental United States), which became a small outpost that never grew very large. More permanent, much larger territories were established in New Mexico and California, with a few in Texas and Arizona, forming part of the colonial history of the United States. Although the Spanish elements in the history of the United States were mostly ignored by American historians in the decades after independence, the concept of the "Spanish borderlands" in the American Southwest was developed by American historians in the 20th century, which integrated Spain into U.S. history. Spain-US relations have been seen as one of "love and hate".

Spain provided indirect support to the new United States by fighting against Great Britain during the American Revolutionary War. Madrid tacitly recognised the independence of the United States in 1783. The purchase of the underdeveloped Spanish Florida by the US was made effective in 1821. The U.S. gave diplomatic support to the breakaway Spanish viceroyalties as they secured their independence around 1820. American diplomatic offers to buy Cuba in the 1850s failed. When Cuba revolted in the late 19th century American opinion became strongly hostile to Spanish rule over Cuba. The Spanish–American War erupted in 1898. The Spanish defeat in the conflict entailed the loss of the last Spanish overseas territories outside north Africa, notably Cuba, Puerto Rico, Guam and the Philippines.

When the Spanish Civil War erupted in 1936, Washington was neutral and banned arms sales to either side; oil sales were allowed. Congress endorsed the embargo by a near-unanimous vote. President Franklin Roosevelt quietly favored the left-wing Republican (or "Loyalist") government, but intense pressure by American Catholics forced him to maintain a policy of neutrality. Spain was carefully neutral in World War II, despite its ties with Nazi Germany.

As the Cold War deepened after 1950, Washington threw a lifeline to the Francoist dictatorship that included financial aid and military bases. Membership in NATO came in 1982, after Francisco Franco's death and the Spanish transition to democracy.

18th century Spain and the American Revolution

Spain declared war on Great Britain as an ally of the Kingdom of France, and provided supplies and munitions to the Continental Army. However Spain was not an ally of the Patriots. It was reluctant to recognize the independence of the United States, because it distrusted revolutionaries. Historian Thomas A. Bailey says of Spain: Although she was attracted by the prospect of a war [against Britain] for restitution and revenge, she was repelled by the specter of an independent and powerful American republic. Such a new state might reach over the Alleghenies into the Mississippi Valley and grasp territory that Spain wanted for herself.Even worse, i (10th ed. 1980) pp 32–33.

Among the most notable Spaniards warriors was Bernardo de Gálvez y Madrid, Count of Gálvez, who defeated the British at Manchac, Baton Rouge, and Natchez in 1779, clearing the lower Mississippi Valley of British forces and relieved the threat to the capital of Spanish Louisiana, New Orleans. In 1780, he recaptured Mobile and in 1781 took by land and by sea Pensacola, leaving the British with no bases in the Gulf of Mexico. In recognition for his actions to the American cause, George Washington took him to his right in the parade of July 4 and the American Confederation Congress cited Gálvez for his aid during the Revolution.Eliga Gould, "Bernardo de Gálvez: Spanish Hero of the American Revolution by Gonzalo M. Quintero Saravia." William and Mary Quarterly 76.3 (2019): 597–600 online.

Floridablanca instructed the Count of Aranda to sign a Treaty with the United States on March 17, 1783, thus making Spain tacitly recognise then the independence of the US.

Another notable contributor was Diego de Gardoqui, who was appointed as Spain's first minister to the United States of America in 1784. Gardoqui became well acquainted with Washington, and also marched in President Washington's inaugural parade. King Charles III of Spain continued communications with Washington, sending him gifts such as blooded livestock from Spain that Washington had requested for his farm at Mount Vernon.

Spain and the United States in the late 18th century

The United States' first ambassador to Spain was John Jay (but was not formally received at court). Jay's successor, William Carmichael, married a Spanish woman and is buried in the Catholic cemetery in Madrid. Some friendly ties were established: George Washington had established the American mule-raising industry with high-quality large donkeys sent to him by the King of Spain (as well as Lafayette).Paul Johnson, A History of the American People (New York: HarperCollins, 1997), 362.

Spain fought the British as an ally of France during the Revolutionary War, but it distrusted republicanism and was not officially an ally of the United States. After the war, the main relationships dealt with trade, with access to the Mississippi River, and with Spanish maneuvers with Native Americans to block American expansion.Samuel Flagg Bemis, The Diplomacy of the American Revolution (1935, 1957) pp 95–102. online Spain controlled the territories of Florida and Louisiana, positioned to the south and west of the United States. Americans had long recognized the importance of navigation rights on the Mississippi River, as it was the only realistic outlet for many settlers in the trans-Appalachian lands to ship their products to other markets, including the Eastern Seaboard of the United States.John Ferling, A Leap in the Dark: The Struggle to Create the American Republic (2003), pp. 211–212

Despite having fought a common enemy in the Revolutionary War, Spain saw U.S. expansionism as a threat to its empire. Seeking to stop the American settlement of the Old Southwest, Spain denied the U.S. navigation rights on the Mississippi River, provided arms to Native Americans, and recruited friendly American settlers to the sparsely populated territories of Florida and Louisiana.Alan Taylor. American Revolutions A Continental History, 1750–1804 (2016), pp. 345–346 Additionally, Spain disputed the Southern and Western borders of the United States. The most important border dispute centered on the border between Georgia and West Florida, as Spain and the United States both claimed parts of present-day Alabama and Mississippi. Spain paid cash to American General James Wilkinson for a plot to make much of the region secede, but nothing came of it.George Herring, From Colony to Superpower: U.S. Foreign Relations Since 1776 (2008), pp. 46–47 Meanwhile, Spain worked on the goal of stopping American expansion by setting up an Indian buffer state in the South. They worked with Alexander McGillivray (1750–1793), who was born to a Scottish trader and his French-Indian wife, and he had become a leader of the Creek tribe as well as an agent for British merchants. In 1784–1785, treaties were signed with Creeks, the Chickasaws, and the Choctaws to make peace among themselves, and ally with Spain. While the Indian leaders were receptive, Yankee merchants were much better suppliers of necessities than Spain, and the pan-Indian coalition proved unstable.Lawrence S. Kaplan, Colonies into Nation: American Diplomacy 1763–1801 (1972) pp 168–71.Jane M. Berry, "The Indian Policy of Spain in the Southwest 1783–1795." Mississippi Valley Historical Review 3.4 (1917): 462–477. onlineArthur P. Whitaker, "Spain and the Cherokee Indians, 1783–98" North Carolina Historical Review 4.3 (1927): 252–269

Spanish merchants welcomed trade with the new nation, which had been impossible when it was a British colony. it therefore encourage the United States to set up consulates in Spain's New World coloniesRoy F. Nichols, "Trade Relations and the Establishment of the United States Consulates in Spanish America, 1779–1809." The Hispanic American Historical Review 13.3 (1933): 289–313. American merchants and Eastern cities likewise wanted to open trade with the Spanish colonies which had been forbidden before 1775.Arthur P. Whitaker, "Reed and Forde: Merchant Adventurers of Philadelphia: Their Trade with Spanish New Orleans" Pennsylvania Magazine of History and Biography 61.3 (1937): 237–262 A new line of commerce involved American merchants importing goods from Britain, and then reselling them to the Spanish colonies.Javier Cuenca-Esteban, "British 'Ghost' Exports, American Middlemen, and the Trade to Spanish America, 1790–1819: A Speculative Reconstruction" William & Mary Quarterly 71.1 (2014): 63–98.

John Jay negotiated a treaty with Spain to resolve these disputes and expand commerce. Spain also tried direct diplomacy offering access to the Spanish market, but the cost of closing the Mississippi to Western farmers for 25 years and blocking southern expansionists. The resulting Jay–Gardoqui Treaty was rejected by a coalition of Southerners led by James Madison and James Monroe of Virginia, who complained that it would hurt their people and instead favored Northeastern commercial interests. The treaty was defeated.Kaplan, 166–174.

Pinckney's Treaty, also known as the Treaty of San Lorenzo or the Treaty of Madrid, was signed in San Lorenzo de El Escorial on October 27, 1795, and established intentions of friendship between the United States and Spain. It also defined the boundaries of the United States with the Spanish colonies and guaranteed the United States navigation rights on the Mississippi River. Both sides remained distrustful. Secretary of State Timothy Pickering feared that Spain might turn over Louisiana to her much more powerful associate France. Spain, by early 1797, was stalling the fulfillment of the 1795 treaty. Finally in 1798 Madrid backed down and relations improved.Gerald H. Clarfield, "Victory in the West: A Study of the Role of Timothy Pickering in the Successful Consummation of Pinckney's Treaty" Essex Institute Historical Collections (1965) 101#4 pp 333–353.

19th century Early 19th century Spanish–American relations declined during the 19th century, as both countries competed for territory and concessions in the New World. "Culturally, they misunderstood and distrusted each other", James W. Cortada has written. "Political conflicts and cultural differences colored relations between the two nations throughout the nineteenth century, creating a tradition of conflict of a generally unfriendly nature. By 1855, a heritage of problems, hostile images, and suspicions existed which profoundly influenced their relations."James W. Cortada, "Spain and the American Civil War: Relations at Mid-century, 1855–1868" (American Philosophical Society, 1980), 3.

During the Peninsular War, when Spain had two rival Kings – the overthrown Bourbon Fernando VII and Napoleon's brother, Joseph Bonaparte, enthroned as José I of Spain – the United States officially maintained a neutral position between them. Ambassador Luis de Onís who arrived in New York in 1809, representing Fernando VII's government, was refused an audience to present his credentials to President James Madison. He was only recognized officially by the US government in 1815, following Napoleon's defeat – though in the meantime he had established himself in Philadelphia and unofficially conducted extensive diplomatic activity.