The victory of the United States, governed by McKinley, in the Spanish American War gave him a boost going into the 1900 presidential election.
An incumbent president often enjoys a boost to his popularity following a brief and victorious war. McKinley gave Americans a new vision for their role in the world, including military dominance in the Western Hemisphere and increased engagement on the world stage. These factors helped him get reelected.