We show that abelian surfaces (and consequently curves of genus 2) over
totally real fields are potentially modular. As a consequence, we obtain the
expected meromorphic continuation and functional equations of their Hasse--Weil
zeta functions. We furthermore show the modularity of infinitely many abelian
surfaces A over Q with End_C(A)=Z. We also deduce modularity and potential
modularity results for genus one curves over (not necessarily CM) quadratic
extensions of totally real fields.Comment: 285 page