deyoshi invaded Korea twice, but following defeats by Korean and Ming Chinese forces and Hideyoshi's death, Japanese troops were withdrawn in 1598. This age is called Azuchi-Momoyama Period (1573–1603).
Tokugawa Ieyasu served as regent for Hideyoshi's son and used his position to gain political and military support. When open war broke out, he defeated rival clans in the Battle of Sekigahara in 1600. Ieyasu was appointed shogun in 1603 and established the Tokugawa shogunate at Edo (modern Tokyo). The Tokugawa shogunate enacted measures including buke shohatto, as a code of conduct to control the autonomous daimyo; and in 1639, the isolationist sakoku ("closed country") policy that spanned the two and a half centuries of tenuous political unity known as the Edo period (1603–1868). The study of Western sciences, known as rangaku, continued through contact with the Dutch enclave at Dejima in Nagasaki. The Edo period also gave rise to kokugaku ("national studies"), the study of Japan by the Japanese.
On 31 March 1854, Commodore Matthew Perry and the "Black Ships" of the United States Navy forced the opening of Japan to the outside world with the Convention of Kanagawa. Subsequent similar treaties with Western countries in the Bakumatsu period brought economic and political crises. The resignation of the shogun led to the Boshin War and the establishment of a centralized state nominally unified under the Emperor (the Meiji Restoration).
Adopting Western political, judicial and military institutions, the Cabinet organized the Privy Council, introduced the Meiji Constitution, and assembled the Imperial Diet. The Meiji Restoration transformed the Empire of Japan into an industrialized world power that pursued military conflict to expand its sphere of influence. After victories in the First Sino-Japanese War (1894–1895) and the Russo-Japanese War (1904–1905), Japan gained control of Taiwan, Korea, and the southern half