In the heavy-quark limit, the two heavy quarks in a doubly heavy baryon or a doubly heavy tetraquark are bound by their color-Coulomb potential into a compact diquark. The doubly heavy hadrons are related by the approximate heavy-quark--diquark symmetry of QCD to the heavy hadrons obtained by replacing the heavy diquark by a heavy antiquark. Effective field theories can be used to expand the masses of singly heavy hadrons and doubly heavy hadrons in inverse powers of the heavy quark masses. The coefficients in the expansions for doubly heavy tetraquarks can be determined from those for heavy mesons, heavy baryons, and doubly heavy baryons using heavy-quark--diquark symmetry. We predict the masses of the ground-state doubly heavy tetraquarks with error bars using as inputs the masses of heavy mesons and heavy baryons measured in experiments and the masses of doubly heavy baryons calculated using lattice QCD. The only doubly heavy tetraquarks predicted to be stable with respect to strong decays are $bb$ tetraquarks with light flavor $\bar u \bar d$, $\bar s \bar u$ and $\bar s \bar d$.