Japanese Combined Fleet commander Admiral Isoroku Yamamoto moved on Midway in an effort to draw out and destroy the U.S. Pacific Fleet's aircraft carrier striking forces, which had embarrassed the Japanese Navy in the mid-April Doolittle Raid on Japan's home islands and at the Battle of Coral Sea in early May. He planned to quickly knock down Midway's defenses, follow up with an invasion of the atoll's two small islands and establish a Japanese air base there. He expected the U.S. carriers to come out and fight, but to arrive too late to save Midway and in insufficient strength to avoid defeat by his own well-tested carrier air power.
Yamamoto's intended surprise was thwarted by superior American communications intelligence, which deduced his scheme well before battle was joined. This allowed Admiral Chester W. Nimitz, the U.S. Pacific Fleet commander, to establish an ambush by having his carriers ready and waiting for the Japanese. On 4 June 1942, in the second of the Pacific War's great carrier battles, the trap was sprung. The perseverance, sacrifice and skill of U.S. Navy aviators, plus a great deal of good luck on the American side, cost Japan four irreplaceable fleet carriers, while only one of the three U.S. carriers present was lost. The base at Midway, though damaged by Japanese air attack, remained operational and later became a vital component in the American trans-Pacific offensive.
UPDATE: Excellent history of the Midway Battle in a series of posts by Steeljaw Scribe- go and read.