The Boshin War (literally, "War of the Year of the Dragon") was a civil war that took place in Japan in 1868 and 1869 which pitted the supporters of the Imperial Court and the Meiji Restoration against the last remaining supporters of the Tokugawa shogunate.
The conflict began on November 9, 1867, when the Imperial Court issued secret authorization to the daimyo of Satsuma and Choshu domains to attack and overthrow the Tokugawa shogunate. Recognizing that he would probably not be able to defeat the armies of these powerful domains, the last Tokugawa shogun, Tokugawa Yoshinobu, initially announced that he would surrender and submit to Imperial will.
However, once Satsuma and Choshu made clear that they would accept nothing less than the total abolition of the office of shogun and the seizure of all of Yoshinobu's lands, he felt compelled to fight. He ordered the Satsuma compound in Edo attacked and burned down and began preparing for an assault on the Imperial Court in Kyoto.
In January of 1868, the shogunal army launched an assault on Satsuma and Choshu forces at Toba-Fushimi just outside Kyoto. Shogunal forces initially outnumbered their enemies 3:1, but when local daimyo began to flock to the Imperial banner, Yoshinobu panicked and fled back to his stronghold in Edo, leaving all of Western Japan in Imperial hands.
The famous Satsuma general Saigo Takamori then led the swelling Imperial army eastward, surrounding Edo and forcing the unconditional surrender of Shogunal Army. Yoshinobu resigned as shogun and allowed himself to be placed under voluntary house arrest in Shizuoka.
With the fall of Edo and the surrender of the shogun, most of Japan accepted Imperial rule. However, the commander of the Shogun's navy, Enomoto Takeaki, refused to give in, escaping northward with eight steam-powered warships and 2000 loyal naval men and several French advisors. Meanwhile, several domains in northeastern Japan, led by the fiercely militant domain of Aizu, refused to recognize the new regime. They welcomed Enomoto's renegade fleet into port at Sendai, and gathered a land army of more than 50,000 men to continue the resistance.
Imperial Forces marched northward, along the Japan Sea, reducing the city of Nagaoka to rubble, defeating the Shinsengumi at the Battle of Bonari Pass, and laying seige to Aizu. With Aizu under seige, the northern coalition collapsed, and the other rebel domains surrendered. Aizu held out for a whole month, but finally surrendered on November 6, 1868.
Admiral Enomoto would still not give up, however. Fleeing Sendai with two additional ships from Sendai domain's navy and the remnants of the Shinsengumi, along with his own men and ships, he relocated to Hokkaido, where he declared an independent and democratic "Republic of Ezo" based on the US Constitution, and held a general election of the populace, in which he was elected the Republic's first president (in what was Japan's first-ever democratic election).
Over the winter he fortified the city of Hakodate, centering his defenses around a new star-shaped fortress, the Goryokaku, and purchasing supplies and modern weapons with 180,000 gold coins he had quietly pilfered from Osaka Castle the year before, when the shogun Yoshinobu had made his headquarters in Osaka while preparing for the attack on Kyoto.
Imperial naval and land forces arrived in Hokkaido the following spring, defeating Enomoto's navy with the help of the Kotetsu, an ironclad warship purchased from the United States which had formerly been the Confederate naval vessel CSS Stonewall. The French advisors fled back to France by sea, and Enomoto resolved to fight to the end, but his second in command Otori Keisuke convinced him to surrender by saying "Living through defeat is truly the more courageous way. If dying is what you want, you can do that anytime." Enomoto surrendered on May 18, 1869, and the Boshin War was over.