Japan invaded Sakhalin in the final stages of the Russo-Japanese War of 1904–1905, but per the 1905 Treaty of Portsmouth was allowed to retain only the southern portion of the island below the 50° N parallel. Russia retained the northern portion, although the Japanese were awarded favorable commercial rights, including fishing and mineral extraction rights in the north. In 1907, Karafuto Prefecture was officially established, with the capital at Ōtomari. In 1908, the capital was relocated to Toyohara.