He played an important role in the Hungarian communist revolution led by Béla Kun in 1919. After four years in Moscow (1920–24), Rakosi returned to Hungary but was later arrested, to be released only in 1940. In 1944 he became First Secretary of the Hungarian Communist Party and during this time established a ruthless Stalinist regime. He was Prime Minister (1952–53). Opposition to his Stalinist policies led to his resignation as Party Secretary and return to the Soviet Union in 1956. The brutality of his secret police contributed to the Hungarian Revolution of 1956.