The aim of this thesis is to address potential causes of ethnic segregation in schools through developing and analyzing an agent-based model. An agent-based model is a computer program where individual agents interact with each other and an environment according to a set of behavioral rules. I argue that agent-based modeling is particularly suitable for theoretical exploration of complex macro-level patterns such as segregation. The thesis includes an overview of the theoretical foundations of agent-based modeling, and discussions of its use in the social sciences. I also discuss analytical sociology, middle-range theory and mechanism-based explanation, in order to provide a theoretical foundation for my methodological approach. The model I have developed for this thesis represents households enrolling their children into schools, based on simple rules of preference regarding the ethnic composition of and the geographical distance to schools. Building on an existing model created by Victor Stoica and Andreas Flache, as well as Thomas Schelling s model of residential segregation, analysis of the model seeks to investigate three central questions regarding the growth and persistence of school segregation. The first question deals with how mild preferences for avoiding being in a small minority among parents affect segregation patterns: Can segregation arise among tolerant parents, as Schelling s model shows regarding neighborhoods, in schools? Second, the effect of including a preference for minimizing home-school distance among parents is examined. Finally, the development of segregation patterns over time is discussed. The results show that Schelling-type mechanisms can operate in schools as well as in neighborhoods. Including a preference for minimizing distance has a curbing effect on segregation, but the effect is dependent on how this preference is modeled. Finally, the model is empirically calibrated to represent a stylized map of Oslo, and the results compared with the purely theoretical model. This comparison shows that the overall behavior of the model is similar when initialized under empirically calibrated conditions, but that the effect of including a preference for minimizing home-school distance among households has a greater effect. Finally, I conclude with discussing the weaknesses of the model, and suggest further extensions for future work.