The Battle of Midway took place from June 4-7, 1942 and was a decisive naval battle between the United States and Imperial Japanese Navy. Through the use of codebreaking, the US discovered Japan's plan to invade Midway Island and ambush the US carriers. This allowed the US Navy to prepare an ambush of its own. During the battle, the US sank four Japanese aircraft carriers, severely damaging Japan's naval air power and turning the tide of the war in the Pacific in favor of the Allies.