We study the structure of gauge and gravitational anomalies in 2d N = (0, 2) theories obtained by compactification of F-theory on elliptically fibered Calabi-Yau 5-folds. Abelian gauge anomalies, induced at 1-loop in perturbation theory, are cancelled by a generalized Green-Schwarz mechanism operating at the level of chiral scalar fields in the 2d supergravity theory. We derive closed expressions for the gravitational and the non-abelian and abelian gauge anomalies including the Green-Schwarz counterterms. These expressions involve topological invariants of the underlying elliptic fibration and the gauge background thereon. Cancellation of anomalies in the effective theory predicts intricate topological identities which must hold on every e...