The Spanish-American War initially started due to the implementation of the Wilson-Gorman Tariff in 1894. This tariff placed restrictions on Cuba's buying and selling of sugar. This lead to a revolt by the Spanish ruled colony of Cuba on Spain resulting in much of the population being put into concentration camps in Cuba. Because of American business interests in Cuba, concern was raised as turmoil continued between Cuba and Spain.
In 1898, the year after President McKinley had taken office, the U.S. sent the U.S.S. Maine to Cuba on a "friendly mission" with the intent of rescuing U.S. citizens potentially in danger due to the conflicts in Cuba. While on it's mission, the U.S.S. Maine blew up allegedly due to a Spanish mine. After this event, McKinley gave the go ahead to declare war on the Spanish to help Cuba gain freedom.
During the war, American forces invaded many other Spanish island colonies around the world.
Despite the unorganized efforts of the American forces in Cuba, the U.S. defeated the Spanish relatively easily. On December 10, 1898, the Treaty of Paris was signed, officially ending the war. Cuba was liberated from Spain by the U.S. and the U.S. gained the former Spanish colonies of Puerto Rico, Guam, and the Philippines.