Casemiro spent last season on loan at Madrid Castilla after arriving from Sao Paolo in December and also made one appearance for Real Madrid against Real Betis.
Real have now activated his €6 million (£5.1m) release clause to make his move to the Bernabeu permanent with the Brazilian signing a four-year deal.
A club statement read: "Real Madrid C.F. have used their purchase option to buy Carlos Henrique 'Casemiro' and as a result he will be a first team player at the club for the next four seasons.
The 21-year-old becomes the club's second signing of the summer following the arrival of Dani Carvajal who rejoined from Bayer Leverkusen.