Aboard the USS Missouri in Tokyo Bay, Japan formally surrenders to the Allies, bringing an end to World War II.

By the summer of 1945, the defeat of Japan was a foregone conclusion. The Japanese navy and air force were destroyed. The Allied naval blockade of Japan and intensive bombing of Japanese cities had left the country and its economy devastated. At the end of June, the Americans captured Okinawa, a Japanese island from which the Allies could launch an invasion of the main Japanese home islands. U.S. General Douglas MacArthur was put in charge of the invasion, which was code-named “Operation Olympic” and set for November 1945.

The invasion of Japan promised to be the bloodiest seaborne attack of all time, conceivably 10 times as costly as the Normandy invasion in terms of Allied casualties. On July 16, a new option became available when the United States secretly detonated the world’s first atomic bomb in the New Mexico desert. Ten days later, the Allies issued the Potsdam Declaration, demanding the “unconditional surrender of all the Japanese armed forces.” Failure to comply would mean “the inevitable and complete destruction of the Japanese armed forces and just as inevitable the utter devastation of the Japanese homeland.” On July 28, Japanese Prime Minister Kantaro Suzuki responded by telling the press that his government was “paying no attention” to the Allied ultimatum. U.S. President Harry S. Truman ordered the devastation to proceed, and on August 6, the U.S. B-29 bomber Enola Gay dropped an atomic bomb on the Japanese city of Hiroshima, killing an estimated 80,000 people and fatally wounding thousands more.

After the Hiroshima attack, a faction of Japan’s supreme war council favored acceptance of the Potsdam Declaration, but the majority resisted unconditional surrender. On August 8, Japan’s desperate situation took another turn for the worse when the USSR declared war against Japan. The next day, Soviet forces attacked in Manchuria, rapidly overwhelming Japanese positions there, and a second U.S. atomic bomb was dropped on the Japanese coastal city of Nagasaki.

READ MORE: Hiroshima, Then Nagasaki: Why the US Deployed the Second A-Bomb

Just before midnight on August 9, Japanese Emperor Hirohito convened the supreme war council. After a long, emotional debate, he backed a proposal by Prime Minister Suzuki in which Japan would accept the Potsdam Declaration “with the understanding that said Declaration does not compromise any demand that prejudices the prerogatives of His Majesty as the sovereign ruler.” The council obeyed Hirohito’s acceptance of peace, and on August 10 the message was relayed to the United States.

Early on August 12, the United States answered that “the authority of the emperor and the Japanese government to rule the state shall be subject to the Supreme Commander of the Allied Powers.” After two days of debate about what this statement implied, Emperor Hirohito brushed the nuances in the text aside and declared that peace was preferable to destruction. He ordered the Japanese government to prepare a text accepting surrender.

In the early hours of August 15, a military coup was attempted by a faction led by Major Kenji Hatanaka. The rebels seized control of the imperial palace and burned Prime Minister Suzuki’s residence, but shortly after dawn the coup was crushed. At noon that day, Emperor Hirohito went on national radio for the first time to announce the Japanese surrender. In his unfamiliar court language, he told his subjects, “we have resolved to pave the way for a grand peace for all the generations to come by enduring the unendurable and suffering what is insufferable.” The United States immediately accepted Japan’s surrender.

WATCH: Japan Surrenders

President Truman appointed MacArthur to head the Allied occupation of Japan as Supreme Commander of the Allied Powers. For the site of Japan’s formal surrender, Truman chose the USS Missouri, a battleship that had seen considerable action in the Pacific and was named after Truman’s native state. MacArthur, instructed to preside over the surrender, held off the ceremony until September 2 in order to allow time for representatives of all the major Allied powers to arrive.

On Sunday, September 2, more than 250 Allied warships lay at anchor in Tokyo Bay. The flags of the United States, Britain, the Soviet Union, and China fluttered above the deck of the Missouri. Just after 9 a.m. Tokyo time, Japanese Foreign Minister Mamoru Shigemitsu signed on behalf of the Japanese government. General Yoshijiro Umezu then signed for the Japanese armed forces, and his aides wept as he made his signature.

Supreme Commander MacArthur next signed, declaring, “It is my earnest hope and indeed the hope of all mankind that from this solemn occasion a better world shall emerge out of the blood and carnage of the past.” Ten more signatures were made, by the United States, China, Britain, the USSR, Australia, Canada, France, the Netherlands and New Zealand, respectively. Admiral Chester W. Nimitz signed for the United States. As the 20-minute ceremony ended, the sun burst through low-hanging clouds. The most devastating war in human history was over.