In 1897, the US convinced Spain to grant Cuba a measure of self-government, but the Cuban rebels wanted total freedom. And on the opposite side of the issue, pro-Spanish Cubans who wanted to keep the status quo of Spanish rule began to riot in Havana.
On January 25, 1898, the American battleship Maine arrived in Havana, to protect Americans there from the riots. On February 15, the ship exploded, killing about 260 people on board.
The cause of the explosion was never determined, but the American public blamed Spain, and took up the cry, "Remember the Maine".
The US pushed Spain for complete independence for Cuba, and , on April 25, 1898, after a few months of applying pressure, declared war. The war was fought in both the Pacific and Atlantic oceans.
Commodore George Dewey sailed from Hong Kong to the Philippines, and destroyed the entire Spanish fleet there (10 ships) on May 1, without a single American loss of life. They eventually stormed and occupied Manila in August.
Cuba was blockaded and eventually invaded, with more destruction of Spanish ships. Puerto Rico was taken with little resistance.
The entire war was over by August 13, 1898. Cuba was granted its independence; the US gained Guam, Puerto Rico and the Philippines.