Pannekoek studied mathematics and physics in Leiden from 1891. Even before he went to college he was interested in astronomy and studied the variability of Polaris. He published his first article, On the Necessity of Further Researches on the Milky Way, as a student. Some years after he had finished his study he started work at the Leiden Observatory (Leidse Sterrewacht), where he wrote his thesis.
After reading Edward Bellamy's Equality, Pannekoek became a convinced socialist and started studying Karl Marx's theories. Soon Pannekoek became a well-known Marxist writer, writing for both Dutch and German magazines. Threatened with dismissal from his job at the observatory for leading a strike support committee and dissatisfied with their outdated methodologies, he decided to move to Berlin, where he became a lecturer at the school funded by the Social Democratic Party of Germany. His radical opinions soon got him in trouble with both the German government and the labor unions.
He was on holiday in the Netherlands when the First World War broke out. Prevented from returning to Germany, he started work as a chemistry and science teacher. Though the Leidse Sterrewacht wanted him back, government opposition because of his Marxist sympathies made this fall through. Instead, the Amsterdam city council got him an appointment at the University of Amsterdam in 1925, first as a part-time professor, and in 1932 as a full professor.