Tokugawa shogunate in 1863 as a special police force to counter pro-imperial and anti-shogunate subversion in Kyōto. The Shinsengumi, lit. “newly established corps”, were first called Rōshigumi (浪士組), as most of its members were rōnin, masterless samurai recruited in Edo (modern-day Tōkyō) in 1863 and sent to Kyōto to protect the shogun who was visiting the city at that time.The Shinsengumi (新撰組 or 新選組) was a small elite group of swordsmen commissioned by the
One of its leaders though, Kiyokawa Hachirō (清河八郎, 1830-1863) was recalled to Edo for expressing pro-imperial sentiments. The remaining thirteen members of the Rōshigumi under Serizawa Kamo (芹沢鴨, 1826-1863) became the founding members of the Shinsengumi. Serizawa was murdered in an internal struggle, and Kondō Isami (近藤 勇, 1834-1868) and Hijikata Toshizō (土方歳三, 1835-1869) emerged as the new leaders. Based in Mibu in Kyōto, the Shinsengumi acted under orders from the Kyōto Shugoshoku (京都守護職, Office of Kyōto Protector), a shogunal office in the period from 1862 to 1868, which was held by Matsudaira Katamori of Aizu for most of its existence and served to keep peace in the city.
The group was involved in the famous massacre at the Ikedaya inn in 1864 and the defence of the Imperial Palace in the Hamaguri Gomon Incident. Even after the Meiji Restoration the Shinsengumi remained loyal to the shōgun, fighting against the Satsuma-Chōshū Alliance in the Boshin War. Hijikata and his men died in the last battle against the imperial forces in Hokkaidō.
The Ikedaya Incident (池田屋事件 Ikedaya jiken) was an armed encounter in July 1864 between the Shinsengumi, at the Ikedaya Inn, located in the outskirts of Kyōto. After extremist forces of the Chōshū Domain had tried to take control of the imperial palace and were expelled from the capital, moderate forces from the Satsuma and the Aizu domains who advocated reconciliation between the imperial court and the shogunate took over politics. In the wake of their expulsion, Chōshū elements sought to regain control of Kyōto and plotted the assassination of Tokugawa leaders and pro-shogunate court nobles. On the night of July 8, 1864, the Shinsengumi under Kondō Isami attacked a gathering of these activists at the Ikedaya Inn. Eight of them were killed and four seriously wounded. Over twenty anti-shogunate activists were arrested, many of them from Chōshū.