Truman made the decision to drop atomic bombs on Nagasaki and Hiroshima in August 1945 in order to put an end to the Pacific portion of World War II. It is hypothesized that this was also a demonstration of power to the USSR, opening the Cold War.
After Germany's surrender in 1945, Truman was faced with ending the war in the Pacific. Japan was dug in, anticipating a land invasion. The U.S. Secretary of War, Henry Stimson, later estimated it would have taken a million or more American casualties to dislodge them, nearly as many as the war had already produced. He further estimated up to two million Japanese would die in the defense.
When the Manhattan Project resulted in a successful test in July, Truman decided to show Japan that a land invasion was unnecessary. He first offered them the opportunity for an unconditional surrender. When they refused, he ordered the military to drop the first bomb, Fat Man, on Hiroshima on Aug. 6. The Soviet Union, freed from its fight in Europe, declared war on Japan on Aug. 8, invading and overwhelming Japanese forces in Manchuria. The bomb Little Boy, the U.S.'s only other atomic bomb, was dropped on Nagasaki on Aug. 9.
On Aug. 10, Emperor Hirohito offered to surrender. Not quite a month later on Sept. 2, the Japanese signed their formal surrender on board the U.S.S. Missouri in Tokyo Bay.