Pressure from American merchants, fueled by yellow journalism, impelled the American government to seek a swift end to the Cuban War of Independence, eventually leading the country to war. America's victory brought the country numerous territorial acquisitions and dealt a huge blow to the psyche of the fading Spanish Empire.
Wikipedia explains that the seeds of the Spanish-American War were planted in the early 19th century when President James Monroe articulated the Monroe Doctrine, according to which the United States would not tolerate further European colonization of the Americas or interference in the affairs of the Western Hemisphere. At first, Cuba was exempt from this declaration. However, by the turn of the 20th century, Cuba had become an important port for American trade.
According to the Library of Congress, Cuba revolted against Spain in 1895. The United States pressed for a swift settlement of the matter. The yellow journalism of Joseph Pulitzer and William Hearst sensationalized the events of the war and led many Americans to sympathize with the Cubans. The public attitude further turned against Spain after the leak of a letter by the Spanish minister in Washington that criticized President William McKinley.
The mysterious sinking of the U.S. Battleship Maine in Havana incited Americans more. In response to political pressures, President McKinley sent Congress a request for armed intervention. Once word of the matter got to Madrid, the Kingdom of Spain declared war on the United States on April 23, 1898. The United States declared war shortly thereafter.