Both clubs had been in talks over a transfer for a number of weeks, with Sociedad's insistence that Madrid met the 23-year-old's €30m (£25.9m) buy-out clause initially holding up the deal.
However, an agreement has now been reached and Illarramendi will sign a six-year deal with the Santiago Bernabeu side upon completion of his medical on Saturday.
Illarramendi is a product of the Sociedad youth academy and has developed into a key player at the Basque side since making his official first team debut in June 2010.
The midfielder was an integral part of the Spain Under-21 squad that were crowned European champions in Israel this summer.
Illarramendi becomes Real Madrid's fourth signing of the summer transfer window after the previous capture of Casemiro, Isco and Daniel Carvajal.
Source:Goal.com