In the troubled times at the end of the Edo period he left his domain without official permission and took part in the movement to overthrow the shogunate. After the Meiji Restoration in 1868, he was employed in the new government, serving as a local official in Niigata Prefecture and other areas. In 1871, when the Ministry of Justice was established, he became attached to it, serving as a judge in various local courts and later as a court president.
In 1891, when the Daishin’in (Supreme Court) was established, he was appointed to head it, but he had only been in this position for a few days when the so-called Otsu Incident occurred. At this time the Russian crown prince Nicolai Alexandrovitch (later Nicolai II) was visiting Japan, and when passing through the town of Otsu on the west shore of Lake Biwa, he was attacked and wfounded by a police officer named Tsuda Sanzo. The government, which was headed at this time by Matsukata Masayoshi and his cabinet, as well as the genro (elder statesmen), fearful of the effect the incident would have on relations with Russia, wanted to have the case handled in the same way as though Tsuda had attacked a member of the Japanese imperial family, which would have resulted in the death penalty for him. In spite of the strong pressure on him, however, Kojima took the position that the charges against Tsuda should be the same as those for attempted murder of an ordinary citizen. He succeeded in persuading the judges in charge of the case of the rightness of this view, and when Tsuda was tried in the Otsu district court by a special session of the Supreme Court, he was so charged and sentenced to life imprisonment. Kojima's action in guarding the independence of the judicature constituted an event of major importance in Japanese legal and political history, and he came in later times to be referred to as the “patron deity” of Japanese law.
About a year after the conclusion of the Otsu Incident, six Supreme Court judges, including Kojima, were accused of gambling at the card game known as hanafuda and were advised by the government that their resignations would be in order. Kojima denied the accusation and submitted himself to a disciplinary trial. The charges against him were dismissed because of lack of evidence, but at the urging of Minister of Justice Yamagata Aritomo and others, he agreed to accept moral responsibility for the affair and in 1892 resigned his position in the Supreme Court. In 1894 he became a member of the Upper House of the Diet and in 1898 he was elected to the Lower House. He became a member of the Upper House once more in 1905.