We lay the foundations for the study of relatively quasiconvex subgroups of relatively hyperbolic groups. These foundations require that we first work out a coherent theory of countable relatively hyperbolic groups (not necessarily finitely generated). We prove the equivalence of Gromov, Osin, and Bowditchs definitions of relative hyperbolicity for countable groups. We then give several equivalent definitions of relatively quasiconvex subgroups in terms of various natural geometries on a relatively hyperbolic group. We show that each relatively quasiconvex subgroup is itself relatively hyperbolic, and that the intersection of two relatively quasiconvex subgroups is again relatively quasiconvex. In the finitely generated case, we prove that every undistorted subgroup is relatively quasiconvex, and we compute the distortion of a finitely generated relatively quasiconvex subgroup.