After returning to Hungary, he participated in the communist movement of Béla Kun and also joined the Party of Communists in Hungary.
During the short-lived 133-day Communist rule after the resignation of President Mihály Károlyi, when the Hungarian Soviet Republic was established, Rákosi served as Deputy People's Commissar for Trade from 21 March to 3 April in the Revolutionary Governing Council led by Sándor Garbai.
Between 3 April and 24 June 1919, Rákosi was one of the six people's commissars for social production, alongside Jenő Varga, Antal Dovcsák, Gyula Hevesi, József Kelen and Ferenc Bajáki.
He was also involved in the Hungarian Red Army's Northern and Eastern military campaigns against the newly formed Czechoslovakia and Romania.
At the end of July 1919, he was promoted to Commander of the internal law-enforcement Red Guard for a short time.

Following the Soviet Republic's fall, Rákosi fled Hungary on 2 August 1919 via the Austrian border, eventually to the Soviet Union where he worked as part of the Communist International, including representing it at the Livorno congress of the Italian Socialist Party.
 After returning to Hungary in 1924, he was imprisoned, but he was released to the Soviet Union in 1940, in exchange for the Hungarian revolutionary banners captured by Russian troops at Világos in 1849.
In the Soviet Union, he became leader of the Comintern.
In 1942, he married divorced lawyer Feodora (Fenia) Kornilova, a woman of Yakut origin.
He returned to Debrecen, Hungary, on 30 January 1945, having been selected by the Soviet authorities to organise the Hungarian Communist Party.
After returning to Hungary, he participated in the communist movement of Béla Kun and also joined the Party of Communists in Hungary. During the short-lived 133-day Communist rule after the resignation of President Mihály Károlyi, when the Hungarian Soviet Republic was established, Rákosi served as Deputy People's Commissar for Trade from 21 March to 3 April in the Revolutionary Governing Council led by Sándor Garbai. Between 3 April and 24 June 1919, Rákosi was one of the six people's commissars for social production, alongside Jenő Varga, Antal Dovcsák, Gyula Hevesi, József Kelen and Ferenc Bajáki. He was also involved in the Hungarian Red Army's Northern and Eastern military campaigns against the newly formed Czechoslovakia and Romania. At the end of July 1919, he was promoted to Commander of the internal law-enforcement Red Guard for a short time.
Following the Soviet Republic's fall, Rákosi fled Hungary on 2 August 1919 via the Austrian border, eventually to the Soviet Union where he worked as part of the Communist International, including representing it at the Livorno congress of the Italian Socialist Party.  After returning to Hungary in 1924, he was imprisoned, but he was released to the Soviet Union in 1940, in exchange for the Hungarian revolutionary banners captured by Russian troops at Világos in 1849. In the Soviet Union, he became leader of the Comintern. In 1942, he married divorced lawyer Feodora (Fenia) Kornilova, a woman of Yakut origin. He returned to Debrecen, Hungary, on 30 January 1945, having been selected by the Soviet authorities to organise the Hungarian Communist Party.
Mátyás Rákosi