As the 19th century drew to a close, tensions had grown between Spain’s declining empire and the rising world power of the United States, which had set its sights on the Caribbean islands to protect its growing sea trade. Under pressure from the United States, Spain granted Puerto Rico  constitutional autonomy and the island was preparing to hold its first self-governing elections when the Spanish-American War was declared in April 1898.
The war was fought mostly in the waters around Cuba and the Philippines, but in May San Juan  was pounded with artillery for three hours from warships led by U.S. Admiral William T. Sampson. The attack was a misguided effort to flush out a Spanish squadron commander who was not in San Juan at the time. Both of San Juan’s major forts sustained damage. The top of El Morro ’s lighthouse was destroyed, and several residences and government buildings were damaged.
In July, 18,000 U.S. troops were sent to secure Puerto Rico . Landing in Guánica , ground troops began working their way northwest to San Juan, but before they could arrive, Spain agreed to relinquish sovereignty over the West Indies. With the signing of the Treaty of Paris in December 1898, Puerto Rico was ceded to the United States.