We present a precise determination of the decay constants of the $D$ and $D_s$ mesons from lattice QCD, obtained through the use of a highly improved discretization of QCD for charm quarks, coupled to gauge configurations generated by the MILC collaboration that include the full effect of sea u, d, and s quarks. We have results for a range of u/d masses down to $m_s/5$ and three values of the lattice spacing, which allow us to perform accurate continuum and chiral extrapolations. We fix the charm quark mass to give the experimental value of the $\eta_c$ mass, and then a stringent test of our approach is the fact that we obtain correct (and accurate) values for the mass of the $D$ and $D_s$ mesons. We compare $f_D$ and $f_{D_s}$ with $f_K$ and $f_\pi$, and using experiment determine corresponding CKM elements with good precision.