The Imperial Court in Kyoto was the nominal ruling government of Japan from 794 AD until the Meiji period ( 1868-1912 ) , after which the court was moved from Kyoto ( formerly Heian-kyō ) to Tokyo ( formerly Edo ) and integrated into the Meiji government .