From Emperor of Japan: Meiji and His World, 1852–1912, by Donald Keene (Columbia U. Press, 2005), Kindle pp. 38-40:
Kōmei became increasingly outspoken in his condemnation of the policy of allowing foreigners into the country. On July 27, 1858, he sent envoys to the Great Shrine of Ise, the Iwashimizu Hachiman Shrine, and the Kamo Shrine to pray for divine protection. In a semmyō [imperial proclamation] he asked the gods, if warfare should break out between Japan and the foreign barbarians, to send a divine wind (kamikaze) like the one that had destroyed the ships of the Mongol invaders in the thirteenth century. He also asked the gods to punish those who, by their failure to repay the blessings they had received from the country, showed themselves disloyal—meaning those who favored opening the country.
Kōmei’s prayers went unanswered. On July 29 the Shimoda magistrate Inoue Kiyonao met with Townsend Harris aboard the warship Powhattan [sic, actually the USS Powhatan), then anchored off Kanagawa, and signed the treaty of amity and commerce between the United States and Japan. The treaty included a schedule of dates during the next five years when ports in addition to Shimoda and Hakodate—Kanagawa (Yokohama), Nagasaki, Hyōgo (Kōbe), and Niigata—were to be opened to foreign ships.
On July 31 the shogunate sent word to the court reporting the conclusion of the treaty with America, explaining that because of the great urgency involved, there had been no time to seek the court’s advice. When the court received this letter, Kōmei was predictably furious. He sent for the chancellor and gave him a letter in which he announced his intention of abdicating the throne.
The emperor had left political matters to the shogunate and had hesitated to express his opinion for fear of worsening relations between the military and the court, but this had led to a difficult situation. At a loss what to do and having only limited ability, he had decided to relinquish the throne. Because Sachinomiya [the future Emperor Meiji] was too young to be his successor at a time when the nation faced a grave crisis, he therefore proposed one of the three princes of the blood. It was definitely not because he desired to lead a life of ease and pleasure that he was abdicating; it was because he wished someone more capable than himself to deal with the problems of state. He asked the chancellor to forward his request to the shogunate.
The letter plainly indicated Kōmei’s dissatisfaction with the shogunate’s inability to handle the foreigners. Although he did not mention this in this letter, he had become increasingly convinced that the foreigners had to be expelled, whatever the cost; their presence in Japan was an affront to the gods and to his ancestors. What makes this and his subsequent letters in a similar vein memorable is the impression they convey of a tormented human being. It is true that much of the phraseology is stereotyped, but no other emperor, at least for hundreds of years, had expressed such bitter frustration, such a sense of powerlessness, despite the grandeur of his title. Kōmei had become a tragic figure, and from this point until the terrible conclusion of his life, he had only brief periods of respite from anger and despair. To find parallels in Japanese history we would have to go back to the exiled emperors Gotoba and Godaigo. Perhaps Richard II, at least as Shakespeare portrayed him, resembled Kōmei even more closely in his awareness of how little control he possessed over his destiny. The barrage of letters Kōmei directed to the officers of his court, lamenting each new development, is without parallel in the correspondence of Japanese sovereigns.