The Brazilian's original deal was set to expire at the conclusion of next season.
But he will now remain with Los Blancos for a further two years after putting pen to paper on fresh terms.
The 29-year-old is the latest player to extend his stay in the Spanish capital after Karim Benzema and Federico Valverde also committed their futures in the past week.
Casemiro has made 288 appearances for Madrid since arriving from Sao Paolo on an initial loan spell in January 2013, scoring 30 goals.
He has enjoyed a trophy-laden spell with the club, winning four UEFA Champions Leagues, three FIFA Club World Cups and LaLiga on two occasions.
The Brazil international was also part of the Selecao squad that won the 2019 Copa America.