The 25-year-old returns to his former club in a reported 17million euro (£12.5m) deal just two years after leaving the San Sebastian outfit to join Los Blancos.
Illarramendi has put pen to paper on a six-year contract with the Basque side, having been linked with Arsenal, Liverpool, Southampton and Tottenham at various points during the transfer window.
A statement from Real Sociedad read: “Real Sociedad and Real Madrid have reached an agreement for the transfer of Asier Illarramendi to our club.
“The player passed a medical this morning before signing his contract in Anoeta.”
Illarramendi, who had four years left on his contract with Madrid, made 59 league appearances for the Bernabeu outfit in his two-year spell at the club.
However, he did not feature in the plans of new Real coach Rafa Benitez and was keen to leave the Spanish giants this summer.
“I’m delighted that everything has been done,” Illarramendi said on Real Sociedad’s official website. “This is what I wanted and what I searched for.
“I’m very happy to return home and I can’t wait to join the team in training and give my best.”
Sociedad, coached by former Manchester United and Everton boss David Moyes, drew 0-0 at Deportivo La Coruna in their Primera Division opener last weekend.
The Basque side host promoted Sporting Gijon on Saturday.