Japan had effectively occupied Korea since 1904. In the waning days of World War II, an agreement was reached between the United States and the Soviet Union: the Soviets would occupy South Korea only as far as the 38th parallel. The United States forces that arrived in Korea were wholly unprepared for their duties in Korea, not understanding its history and relationship with Japan. To many Koreans, independence and unification were their most important goals.
The United States, after much fumbling, supported Syngman Rhee, a Korean nationalist who had been exiled to the United States in 1907. The United States asked the United Nations to settle the issue of a divided Korea. Despite Soviet objections, a United Nations commission voted for elections in Korea. The communists in the South boycotted the election, and refused to allow it in the North. In the South, conservative parties allied with Rhee received a majority of the vote, in an election in which 80% of eligible Korean voters took part. Rhee became President of the newly-declared independent South Korea in October 1948. The Soviets installed Kim II Song as the leader of the North.
As the United States drew down its military in the post war period, the American garrison of 40,000 quickly withered to a force of 472 officers and men who made up the Korean Military Advisory Group (KMAG). The Korean army, known as ROK, was given only light weapons. The North Korean Army, on the other hand, was heavily equipped with tanks and other armored vehicles. The communist victory in China, combined with the first Soviet nuclear tests in 1949, resulted in a new US policy of containment in Asia. The policy, called NSC 48/2, called for the containment to be primarily non-military, with economic and military aid given to non-communist regimes in Asia.
On January 5, 1950, Secretary of State Dean Acheson, speaking at the National Press Club, articulated the American policy. He spoke of those countries that the US would defend with force: Japan, the Rykus islands and the Philippine Islands. Korea was left out. The withdrawal of the last American forces from Korea, as well as North Korean Kim's conviction that the US would not intervene, convinced the North Koreans to attempt to unify the country by force. The Soviets, led by Stalin, and the Chinese, led by Mao, concurred with both Kim's judgement about the United States and his plans to unify the country by force. In June, he struck.