Motivation for ray class groups

Almost all books on class field theory define ray class groups out of nowhere and proceed to prove highly nontrivial theorems on them. One naturally wonders; Where do they come from? Of course, it's easy to answer this question when the base field is the field of rational numbers. However, it's not clear to me at all when the base field is not the field of rational numbers.

-
It's a tribute to Weber, Hilbert and others from the late 19th century that they formulated good concepts while lacking concrete examples beyond the rationals. But they did have another concrete setting: base field an imaginary quadratic field and the theory of complex multiplication. One point to keep in mind is that once we have the idea that an unramified abelian extension of $K$ has its Galois group closely related to the ideal class group of $K$, we can ask if there are abelian extensions of $K$ whose Galois groups are related to generalized ideal class groups in a similar way. –  KCd May 24 '12 at 23:03
Thanks. I guess the ray class groups came from the theory of complex multiplication. Both Weber and Takagi were studying it. –  Makoto Kato May 25 '12 at 5:01