Mendilibar left the Estadio El Sadar on Tuesday after Osasuna lost their three opening La Liga games, scoring just one goal in the process.
And the club have now confirmed that Gracia will take charge immediately, signing a two-year deal.
Gracia managed Almeria last season, guiding them back into La Liga after their relegation a year earlier.
The 43-year-old, who represented the likes of Real Sociedad and Villareal during his playing career, will face Getafe at the Coliseum Alfonso Perez in his first match in charge on September 15.
Getafe are second bottom of the Spanish top flight having only gained a point so far in their campaign.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.