Rákosi had been involved in left-wing politics since his youth, and in 1919 he was a leading commissar in the short-lived Hungarian Soviet Republic. After the fall of the Communist government, he escaped the country and worked abroad as an agent of the Comintern. He was arrested in 1924 after attempting to return to Hungary and organize the Communist Party underground, and would ultimately spend over fifteen years in prison. He became a cause célébre in the international Communist movement, and the predominantly Hungarian Rakosi Battalion of the International Brigades in the Spanish Civil War bore his name. Rákosi was finally allowed to leave for the Soviet Union in 1940 in exchange for prized battle flags captured by Tsarist Russian forces after the Hungarian Revolution of 1848.