The 29-year-old midfielder, whose contract was to expire at the end of the 2022 season, joined from Bayern Munich after winning the World Cup with Germany in 2014. He has helped Real Madrid win 11 titles, including three Champions Leagues and a Spanish league.
Madrid just completed one of its worst seasons in recent years with a 2-0 home loss to Real Betis. The club finished third, eight points behind Atletico Madrid and 19 points behind champion Barcelona.
Madrid is expected to revamp most of its squad under Zinedine Zidane, who returned as coach near the end of the season.