The correct answer is: The samurai and daimyo restored the emperor to power and worked to reform Japan.
Indeed, Japan had remained fiercely isolated from the rest of the world for centuries. Japan especially mistrusted Western powers sine they had better technology and were extremely aggressive and powerful. In 1853, American Commodore Matthew C. Perry, arrived with four US military, steam-powered ships which were equipped with very modern and destructive guns. The Japanese had no means to oppose him in any manner and yielded to his demands, that Japan sign an official treaty if trade and commerce with the United States. This treaty, the Convention of Kanagawa angered many of the highest-ranking samurais for whom it was seen as a capitulation. They decided that Japan was way behind Western powers and that unless they imposed radical societal, economic reforms, they would be dominated by the West. They managed to remove Tokugawa Yoshinobu, the last Shogun of Japan and restored the Emperor.
Traditionalist samurais were incensed by this action and a civil war ensued, which reformist samurais were able to win with the help of Western technology and military advisors. Most power was transferred to the Emperor and Japan started massively importing technology and methods of social organization from many different countries in the west.