Anomalous Hall effect in a two-dimensional electron gas