Simultaneously, he pursued his interests in Marxism. His political and philosophical writings drew the attention of the German Social Democratic Party SPD. In 1906 the SPD invited Pannekoek to come to Berlin to teach historical materialism and write for their political journal. Pannekoek remained in Germany for eight years becoming a major theoretician of anti-authoritarian revolutionary socialism. At the start of the First World War, Pannekoek was deported back to the Netherlands.
In the Netherlands, Pannekoek pursued a return to professional astronomy. An opportunity came in 1918 when Willem de Sitter suggested him as his assistant director of the Leiden Observatory. However, Leiden University which was supervised by the national government, wanted to avoid hiring a known communist and rejected Pannekoek. Instead, Pannekoek was hired by the University of Amsterdam, which was a municipal university at that time. In Amsterdam, Pannekoek founded a new astronomical institute in 1921.
Initially, Pannekoek's main interest was in galactic astronomy. He measured the brightness of the Milky Way and statistically determined the distances to galactic clusters, which he found to be more distant than previously thought. Soon, however, his interests switched to astrophysics. He helped develop the theory of ionization in stellar atmospheres and was the first to create a curve of growth for a star.
After his retirement in 1942, Pannekoek's main focus shifted to the history of astronomy, where he was particularly interested in the social factors that accompanied the development of astronomy.