  We prove that, in a general higher derivative theory of gravity coupled to
abelian gauge fields and neutral scalar fields, the entropy and the near
horizon background of a rotating extremal black hole is obtained by extremizing
an entropy function which depends only on the parameters labeling the near
horizon background and the electric and magnetic charges and angular momentum
carried by the black hole. If the entropy function has a unique extremum then
this extremum must be independent of the asymptotic values of the moduli scalar
fields and the solution exhibits attractor behaviour. If the entropy function
has flat directions then the near horizon background is not uniquely determined
by the extremization equations and could depend on the asymptotic data on the
moduli fields, but the value of the entropy is still independent of this
asymptotic data. We illustrate these results in the context of two derivative
theories of gravity in several examples. These include Kerr black hole,
Kerr-Newman black hole, black holes in Kaluza-Klein theory, and black holes in
toroidally compactified heterotic string theory.
