The immediate origins of the 1898 Spanish-American War began with the Wilson-Gorman Tariff of 1894. The American tariff, which put restrictions on sugar imports to the United States, severely hurt the economy of Cuba, which was based on producing and selling sugar. In Cuba, then a Spanish colony, angry nationalists known as the insurrectos began a revolt against the ruling Spanish colonial regime. When Spain sent in General "Butcher" Weyler to stabilize the situation in Cuba, he put much of the population in concentration camps. The US, which had many businessmen with investment interests in Cuba, became concerned. The American public was stirred into an anti-Spain frenzy by the yellow journalism of men like Hearst and Pulitzer. Nonetheless, President Grover Cleveland promised he would not go to war.
By the time President McKinley came into office in 1897, the uproar over Cuba was continuing, even though Weyler had left. In 1898, the US dispatched the USS Maine on a "friendly" mission to Cuba. The ship was to wait, ready to rescue US citizens who might be endangered by the conflict in Cuba. On February 15, 1898 the Maine mysteriously blew up. The US blamed a Spanish mine. McKinley gave the OK for war, and by April, both the US and Spain had declared war. In order to assure the world that it was fighting only for the good of Cuba and not for colonial gain, the US passed the Teller Amendment, which promised to make Cuba independent after the war was over.
Once declared, the US fought the war on a number of fronts including Cuba itself. Upon the commencement of hostilities, on the orders of Assistant Secretary of the Navy Theodore Roosevelt, Commodore Dewey immediately attacked Manila harbor in the Philippines. On May 1, Dewey destroyed the old, decrepit, and rotting Spanish fleet at Manila, and the US prepared for an invasion of the Philippines. The US also invaded Guam and Puerto Rico, other Spanish island colonies, during the war.
Under the leadership of General William R. Shafter, the US ground effort in Cuba was far from organized. Nonetheless, with heroics from the famous Rough Riders and other units, the war was never in much doubt and the US defeated the Spanish with relatively little difficulty. On December 10, 1898, the Treaty of Paris was signed, ending the war. The US liberated Cuba, and got Puerto Rico, Guam, and the Philippines as colonies for itself.
After the war, the US made improvements in Cuban infrastructure and educational systems, and prepared to leave. But in 1901, before leaving, the US forced the Cubans to insert the Platt Amendment into their constitution, which gave the US a military base on the island (Guantanamo). Guam, Puerto Rico, and the Philippines all became American protectorates, whose people, as the Insular Cases by the Supreme Court found, did not have full rights as American citizens. Some of the people in these new colonies were understandably upset, since they expected that they would be liberated just as Cuba had. Instead, the US kept the island colonies as coaling stations for its ships. Immediately after being annexed by the US, in January 1899 the Filipinos declared themselves independent, beginning a guerilla war against the US, led by Emilio Aguinaldo. The rebellion lasted over a year, until March of 1901, when the US captured Aguinaldo.