After his financial support from Cuba came to an end, Lam sustained himself by undertaking commissions for realistic portraits. In 1929 he married Eva Píriz. However, she and their young son Wilfredo both died of tuberculosis in 1931, and Lam was overwhelmed by this personal disaster. As he recovered over the following years, he experimented with styles influenced by modernist artists such as Pablo Picasso and Henri Matisse.
Lam was part of a vibrant cultural circle in Madrid. In 1936, when General Franco led the right-wing uprising that triggered the Spanish Civil War, Lam volunteered for the Republican militia. He worked in a munitions factory but, after six months handling toxic substances, his health deteriorated and he withdrew to Catalonia to recuperate. The tragedy of the Civil War became a frequent theme in his paintings, which concentrated on simplified and schematised figures. Placing his art at the service of the Republic he also made images reminiscent of Goya, condemning the horrors of war. Among Lam’s contacts in war-torn Barcelona was the sculptor Manolo Hugué who urged him to leave for Paris and provided him with an introduction to Picasso.