Modric's previous contract was set to expire at the end of this month.
But the 37-year-old has joined fellow veteran Toni Kroos in adding 12 more months to his existing deal.
Modric had been linked with a move to the Saudi Pro League.
The Croatia international has made 488 appearances for Real Madrid since moving to the Santiago Bernabeu from Tottenham Hotspurs in 2012.
He has won among others five UEFA Champions League trophies, three La Liga titles, two Copa del Reys and five FIFA Club World Cups.
On an individual level, Modric won the prestigious Ballon D'or award in 2018.
A statement from Real Madrid read: “Real Madrid and Luka Modric have agreed to extend the player’s contract, which remains linked to the club until June 30 2024.”
"Luka Modrić joined Real Madrid in 2012. During his eleven seasons in our jersey he's made 488 appearances and won 23 trophies: 5 Champions League, 5 Club World Cups, 4 European Super Cups, 3 LaLiga titles, 2 Copa del Rey and 4 Spanish Super Cups.
"Modrić has won the ultimate individual awards during his career as a Real Madrid player, including the 2018 Ballon d'Or, the 2018 FIFA The Best Player of the Year Award, the 2017/18 UEFA Player of the Year Award, the 2017 Club World Cup Golden Ball, and this season he was part of the FIFA/FIFPro World XI for the sixth time in his career."
He also won the Golden Ball at the World Cup in Russia and the Bronze Ball at the World Cup in Qatar."
Following an announcement of his new contract in the Spanish capital, Modric wrote "Home Sweet Home," on Twitter.