Puerto Rico was part of the Spanish Empire for four centuries, during which the people of Puerto Rico defended themselves against invasions from the British, French, and Dutch. Puerto Ricans fought alongside General Bernardo de Gálvez during the American Revolutionary War in the battles of Baton Rouge, Mobile, Pensacola and St. Louis. During the mid-19th century, Puerto Ricans residing in the United States fought in the American Civil War. In the 1800s, the quest for Latin American independence from Spain spread to Puerto Rico, in the short-lived revolution known as the "Grito de Lares" and culminating with the "Intentona de Yauco". The island was invaded by the United States during the Spanish–American War. After the war ended, Spain officially ceded the island to the United States under the terms established in the Treaty of Paris of 1898. Puerto Rico became a United States territory and the "Porto Rico Regiment" (Puerto Rico's name was changed to Porto Rico) was established on the island.