In 1183, the Taira loss at the Battle of Kurikara was so severe that they found themselves, several months later, under siege in Kyoto, with Yoshinaka approaching the city from the north and Yukiie from the east. Both Minamoto leaders had seen little or no opposition in marching to the capital and now forced the Taira to flee the city. Taira no Munemori, head of the clan since his father Kiyomori's death, led his army, along with the young Emperor Antoku and the Imperial regalia, to the west. The cloistered emperor Go-Shirakawa defected to Yoshinaka. Go-Shirakawa then issued a mandate for Yoshinaka to "join with Yukiie in destroying Munemori and his army".:293-294 In 1183, Yoshinaka once again sought to gain control of the Minamoto clan by planning an attack on Yoritomo, while simultaneously pursuing the Taira westward. The Taira set up a temporary Court at Daaifu in Kyūshū, the southernmost of Japan's main islands. They were forced out soon afterwards by local revolts instigated by Go-Shirakawa, and moved their Court to Yashima. The Taira were successful in beating off an attack by Yoshinaka's pursuing forces at the Battle of Mizushima.:295-296 Yoshinaka conspired with Yukiie to seize the capital and the Emperor, possibly even establishing a new Court in the north. However, Yukiie revealed these plans to the Emperor, who communicated them to Yoritomo. Betrayed by Yukiie, Yoshinaka took command of Kyoto and, at the beginning of 1184, set fire to the Hōjūjidono, taking the Emperor into custody. Minamoto no Yoshitsune arrived soon afterwards with his brother Noriyori and a considerable force, driving Yoshinaka from the city. After fighting his cousins at the bridge over the Uji, Yoshinaka made his final stand at Awazu, in Ōmi Province. He was defeated by Yoshitsune, and killed while attempting to flee.:296-297
Question: Which happened first, the loss of Kyoto or the Emperor being taken into custody?
Answer: Yoshinaka took command of Kyoto