We use time-dependent spin-density-functional theory to study dynamical
magnetic phenomena. First, we recall that the local-spin-density approximation
(LSDA) fails to account correctly for magnetic fluctuations in the paramagnetic
state of iron and other itinerant ferromagnets. Next, we construct a
gradient-dependent density functional that does not suffer from this problem of
the LSDA. This functional is then used to derive, for the first time, the
phenomenological Gilbert equation of micromagnetics directly from
time-dependent density-functional theory. Limitations and extensions of Gilbert
damping are discussed on this basis, and some comparisons with phenomenological
theories and experiments are made