After Germany surrendered in 1945, ending World War II in Europe, the Allies, including the U.S., France, England and the Soviet Union, demanded Japan's unconditional surrender. The Japanese refused, meaning the Allies would have to invade the Japanese mainland, ensuring a bloody and expensive campaign to take the territory step by step.
In the meantime, by the end of July, 1945, the U.S. had finished work on two atomic bombs, one uranium based and one plutonium based. When the Japanese refused to surrender, President Truman authorized the use of these bombs. On August 6, the first atomic bomb was dropped on Hiroshima, destroying the city and killing about 100,000, half on the first day. On August 9, when the Japanese had still not surrendered, the U.S. dropped a second bomb, this one plutonium based, on the city of Nagasaki. This led to between 39,000-80,000 deaths. While the U.S. had already done multiple fire bombings of Japanese cities, killing many, many civilians, the scale and immediacy of the atom bomb destruction was stunning and unprecedented. After the devastation of Nagasaki, the Japanese realized they were outmatched, and signed an unconditional surrender.
At the time, the U.S. justified the bombings as saving the U.S. and its allies from high casualty rates in a ground invasion of Japan, but in the intervening years, the morality of the decision to drop bombs of such destructive magnitude on areas with civilian populations has been strongly questioned.