After the explosion of the USS Maine, the US public was whipped up into an anti-Spanish hysteria. Despite Spain's desire to avoid war and President William McKinley's distaste for war, the yellow press continued feeding the public's appetite for anti-Spanish news. Hawks like then-Assistant Secretary of the Navy Theodore Roosevelt loudly criticized the reluctant McKinley for being weak and afraid.
Although he disagreed with the public's demands for war, McKinley finally submitted to the various pressure exerted on him. The Maine had exploded in Mid-February, and on April 11, 1898, McKinley finally sent a message to Congress giving his support for a declaration of war on Spain. Congress, which now had the President's word that he would not block a war with Spain as Cleveland had threatened to do, was ecstatic. On April 24, 1898 Spain declared war on the US. The next day, on April 25, the US declared war on Spain. The US public was exuberant, and the people celebrated as the country cheerfully went to war.
In order to prove the righteousness of the US cause, Congress decided to send a message to the European powers, many of whom believed the American war against Spain to be an imperialistic land-grab, an effort to assume control of Cuba from Spain. Congress passed the Teller Amendment in May 1898, in which the US promised not to annex Cuba, but to liberate it as an independent state. Thus, the US claimed to be fighting the war not for selfish gain, but to liberate an oppressed people and promote justice in the world.
Even directly before the war, some people on both sides were trying to avoid conflict. Spain wanted to avoid war at all costs, and the Spanish diplomats to Washington promised to end the concentration camps and make peace with the insurrectos. The US would not have it, demanding only one thing: complete Spanish withdrawal from Cuba and a recognition of Cuban independence. Spain refused. American public opinion now rested decidedly against the Spanish, and because of the way the yellow press had covered the explosion of the USS Maine, most of the country distrusted everything the Spanish said.
Oddly enough, President McKinley also opposed the War. McKinley, who was closely tied to Wall Street and business networks, knew that most businessmen were against going to war. Mark Hanna, wealthy businessman and a leading advisor of McKinley, told McKinley to try and avoid war. Businessmen did not want a war with Spain because they feared that the destabilizing effects of a war might hurt the US economy. So why didn't McKinley use his powers as Commander-and-Chief to prevent the war from being carried out, as President Cleveland had threatened to do a few years earlier? The question was one McKinley wrestled with. A staunch believer in the democratic process, it was McKinley's personal philosophy that the people should get what they wanted, even if he knew that what they wanted would end up being bad for them.
McKinley had other concerns behind his decision to go to war. He was constantly being criticized by Theodore Roosevelt and other warmongers for a "lack of backbone". (Of course, in the hysterical frenzy of 1898, not supporting war was actually a very brave stand.) McKinley also was afraid that not going to war would give the Democrats and his arch-nemesis, William Jennings Bryan, a campaign issue to use against the Republicans in 1900. McKinley knew that if he refused to send in the troops after Congress declared war, the Democrats would use this fact to destroy him in the 1900 election. Finally, a highly devout Christian, McKinley claimed to have been commanded in a dream to send the country to war. Conveniently, the religious experience coincided perfectly with the various pressures forced on McKinley at the time. And even at the same time as he committed the US to war because of a belief in democracy and a religious experience, he still couldn't help but hope that, "perhaps it will pay."
In passing the Teller Amendment, the US was trying to prove itself different from the European imperialist powers by not annexing territory as everyone expected it to, but actually opposing imperialist oppression in the world. Of course, pushing Spain out of Cuba would serve American interests even if the US did not formally own Cuba. US business would still have a dominant trade with an independent Cuba and pushing the Spanish out would create more a more stable and safe shipping zone in the Caribbean. As events would show, US behavior in the war did not exactly accord to the spirit of the Teller Amendment, though Cuba was allowed its independence.