For u in {0,1} let K_u(X) be the set of isomorphism classes of quadratic number fields K with |disc(K)| < X that are imaginary (u = 0) or real (u = 1). For each fixed odd prime p and each finite abelian p-group A, prove that the limit as X tends to infinity of #{K in K_u(X) : Cl(K)[p^infinity] is isomorphic to A} / #K_u(X) exists and equals (1/Z_u(p)) * |A|^{-u} / |Aut(A)|, where Z_u(p) is the sum over isomorphism classes of finite abelian p-groups B of |B|^{-u}/|Aut(B)| (so Z_0(p) = prod_{i>=1}(1-p^{-i})^{-1} and Z_1(p) = prod_{i>=2}(1-p^{-i})^{-1}). Cl(K) is the ordinary ideal class group and Cl(K)[p^infinity] its Sylow p-subgroup. No assertion is made for p = 2, for narrow class groups, for a joint law over several primes, or for any non-quadratic family.