We describe globally nilpotent differential operators of rank 2 defined over a number field whose monodromy group is a nonarithmetic Fuchsian group. We show that these differential operators have an S-integral solution. These differential operators are naturally associated with Teichmueller curves in genus 2. They are counterexamples to conjectures by Chudnovsky--Chudnovsky and Dwork. We also determine the field of moduli of primitive Teichmueller curves in genus 2, and an explicit equation in some cases.