International Intervention
The Korean War was one of those rare instances in history where the United Nations was not entirely useless. The US called upon the UN Security Council to label North Korea as an aggressor, and proceeded to land forces in South Korea to stop another country becoming communist. The US forces were joined by the United Kingdom and the British Commonwealth of Nations, as well as several other anti-communist countries.
The Tide Turns
The arriving pro-South Korean forces, led by the US, struggled but succeeded in slowing down the North Korean advance. Then, as more and more reinforcements arrived, the UN forces began to push back against the North Korean Peoples' Army. With a daring US landing behind the enemy lines at Inchon, and with the aid of UN naval and air superiority, North Korea's military broke and the UN forces chased them back, far into North Korea, even past the North Korean capital of Pyongyang. Seeing such a positive outlook for the war, the US began planning to "liberate" the entirety of Korea from communism.
China Joins the War
The communist government of China was worried that this wave of US-led anti-communist war would cross the Yalu River and attempt to remove communism in China, too. Therefore, when North Korea asked the USSR for aid in the war, it was China who came to the rescue of its fellow Communist regime. The Chinese had the element of surprise, as well as Soviet jet fighters which were able to briefly challenge US air superiority. China's forces pushed the UN troops far back, with the front lines crossing the 38th Parallel once more.
Stalemate
After some more fighting, the war was back to where it started - the front lines were aligned roughly on the 38th Parallel, and it was here that the final stalemate took place. UN troops stared at communist troops, who stared back at them - with no land gains or losses being made. Eventually, a truce was called and a demilitarized zone was created between the combatants. This line can be seen even today, as it still serves for the border between North and South Korea.