The Brazil international is one of the longest serving players at the Bernabeu, having joined the club from Fluminense in January 2007, and he has gone on to make nearly 300 appearances in all competitions.
The 29-year-old has also won 17 major honours during his time in the Spanish capital, including four La Liga titles and three Champions League crowns.
Marcelo is yet to put pen to paper on the contract but Real have confirmed the deal has been agreed in principle and he will officially sign the extension at a press conference on Thursday.
A Real Madrid statement read: "Real Madrid C. F. and Marcelo have agreed to extend the player's contract, which will see him remain at the club until 30 June 2022.
"Tomorrow, Thursday, at 2pm, Marcelo will appear before the media in the press room of the Santiago Bernabeu stadium."