The Moroccan midfielder will depart Tynecastle after his contract expires at the end of May.
Mehdi, signed by former boss Jim Jefferies, joined the club in the summer of 2011 from Kilmarnock following a four-year spell at Rugby Park.
He made 68 appearances in a maroon shirt, including a run out as a substitute in the 5-1 Scottish Cup Final triumph over Hibernian last May.
Also leaving Hearts at the end of his contract after two years in Gorgie will be left-back Danny Grainger as well as Darren Barr, Gordon Smith, Denis Prychynenko and George Scott.
- Sports & Recreation