It is further evidence of Madrid investing in youth with Illarramendi joining Isco, another new recruit and a fellow member of the Spain side which recently won the European Under-21 Championship in Israel, at the Bernabeu.
"The player will be presented tomorrow after undergoing the relevant medical tests."
Illarramendi rose to prominence at Sociedad last season, playing an important role as they finished fourth in the Primera Division, securing a place in the Champions League in the process.
The 23-year-old said at a press conference: "I want to thank Real Sociedad for everything they have given me. I came here as a child, and leave here as a man.
"I would prefer to say 'until next time' rather than goodbye. This will always be my club."
Illarramendi accepts his life is now set to change due to the increased scrutiny in the capital.
"Madrid will be different, there will be more attention on me there," he said.
"I will give my all and we'll see what happens. I'll give everything in every training session and if I get the chance to play I'll also give my all.