"Real Madrid C. F. and VfB Stuttgart have agreed to the transfer of Sami Khedira, who will sign a 5-year contract with Real Madrid," Real said in a statement on their website.
Khedira will become the fourth signing for Real coach Jose Mourinho in the close season.
Los Meringues, who are aiming to dethrone arch-rivals and La Liga holders Barcelona, have also signed winger Angel Di Maria and midfielders Sergio Canales and Pedro Leon.
Khedira was a regular member of Germany's starting line-up at the World Cup finals in South Africa where they finished third.
The 23-year-old produced some solid displays in the heart of the team's midfielder alongside Bastian Schweinsteiger.
He scored in the three-time world champions' 3-2 victory over Uruguay in the third-place playoff.