Radicalized by his experiences in the war, Rajkosi joined the Hungarian Communist Party when he returned to Hungary in 1918. He was commander of the Red Guard in the Soviet Republic established by Bela Kun in 1919.
Admiral Miklos Horthy, commander-in-chief of the Imperial and Royal Fleet, returned to Hungary in November 1919 and led the overthrow of the Soviet Republic. Rakosi fled to Russia and with the support of Joseph Stalin became secretary of Comintern.
Rajkosi returned to Hungary in 1924 but the following year he was imprisoned by Horthy's government. On his release in 1940 Rajkosi moved to the Soviet Union and remained in Moscow for the rest of the Second World War.
When the Red Army liberated Hungary from the German Army in 1945, Rajkosi returned and became general secretary of the Hungarian Communist Party. In elections held in November, 1945, the Hungarian Communist Party won only 20 per cent of the votes. However, the communist filled all the important posts with Rajkosi becoming the most important political figure in Hungary.
The Hungarian Communist Party became the largest single party in the elections in 1947 and served in the coalition People's Independence Front government. With Rajkosi as prime minister, the communists gradually gained control of the government and when Laszlo Rajk, the foreign secretary, criticized attempts by Joseph Stalin to impose Stalinist policies on Hungary he was arrested, tried for treason and executed.
Rakosi now attempted to impose authoritarian rule. An estimated 2,000 people were executed and over 100,000 were imprisoned. These policies were opposed by some members of the Hungarian Communist Party and around 200,000 were expelled by Rakosi from the organization.
Rakosi had difficulty managing the economy and the people of Hungary saw living standards fall. His government became increasingly unpopular and when Joseph Stalin died in 1953 Rakosi was replaced as prime minister by Imre Nagy. However, he retained his position as general secretary of the Hungarian Communist Party and over the next three years the two men became involved in a bitter struggle for power.
He was removed from office in 1956 and in 1962 was expelled from the Hungarian Communist Party. Matyas Rajkosi died in 1971.