Orwell served as both a private and a corporal in Catalonia and Aragon from December 1936 until June 1937. The political party whose militia he served with (the POUM, an anti-Stalinist communist party) was declared an illegal organization and Orwell was subsequently forced to flee or face imprisonment.
By his own admission, Orwell joined the POUM rather than the Communist-run International Brigades by chance—but his experiences, in particular his and his wife's narrow escape from the Communist purges in Barcelona in June 1937,  greatly increased his sympathy for POUM and, while not challenging his moral and political adhesion to the cause of Socialism and Marxism, made him a lifelong anti-Stalinist.Because of the book's criticism of the Communists in Spain, it was rejected by Gollancz, who had previously published all Orwell's books, and Orwell finally found a sympathetic publisher in Frederic Warburg. Warburg was willing to publish books by the dissident left, that is, by socialists hostile to Communism.
To read the book, go here.