Berger's views on World War I were complicated by the Socialist view and the difficulties surrounding his German heritage. However, he did support his party's stance against the war. When the United States entered the war and passed the Espionage Act of 1917, Berger's continued opposition made him a target. He and four other Socialists were indicted under the Espionage Act in February 1918; the trial followed on December 9 of that year, and on February 20, 1919, Berger was convicted and sentenced to 20 years in federal prison.