We find a new class of metastable de Sitter solutions in compactifications of six-dimensional supergravity motivated by type IIB or heterotic string vacua. Two Fayet-Iliopoulos terms of a local U(1) symmetry are generated by magnetic flux and by the Green-Schwarz term canceling the gauge anomalies, respectively. The interplay between the induced D term, the moduli dependence of the effective gauge coupling, and a nonperturbative superpotential stabilizes the moduli and determines the size of the extra dimensions.