The out-of-favour Moroccan midfielder had just six months left on his three year deal at Villa and would almost certainly have left the club in the summer anyway.
Hadji, who made a total of 42 appearances for Villa following his move from Coventry in July 2001 and scored 3 goals, is to sign for Espanyol on a contract that will last until the end of the season with the Spanish side.