Most of Moldovan territory was a part of the Principality of Moldavia from the 14th century until 1812, when it was ceded to the Russian Empire by the Ottoman Empire (to which Moldavia was a vassal state) and became known as Bessarabia. In 1856, southern Bessarabia was returned to Moldavia, which three years later united with Wallachia to form Romania, but Russian rule was restored over the whole of the region in 1878. During the 1917 Russian Revolution, Bessarabia briefly became an autonomous state within the Russian Republic, known as the Moldavian Democratic Republic. In February 1918, the Moldavian Democratic Republic declared independence and then integrated into Romania later that year following a vote of its assembly. The decision was disputed by Soviet Russia, which in 1924 established, within the Ukrainian SSR, a Moldavian autonomous republic (MASSR) on partially Moldovan-inhabited territories to the east of Bessarabia.