The United Nations sent military forces, largely made up of the U.S. military, to aid South Korea. When a huge UN counter-offensive led by General Douglas MacArthur pushed the North Korean army back behind the 38th Parallel and not quite to the Yalu River, neighboring Communist China came to the aid of North Korea.
Click on the map below.
Chinese guerilla warfare pushed back the UN forces below the 38th parallel. The Soviet Union supplied the North Koreans and Chinese armies with weapons. The possibility of nuclear war was eminent now that both the Soviet Union (aiding North Korea) and the United States (aiding South Korea) were involved. An agreement was made to stop the war and divide Korea near the 38th Parallel. To this day, North Korea has a communist government while South Korea has a democratic government.