The Welshman, who joined the Liga side from Tottenham in 2013 for a world-record fee of £85.3 million, will confirm the deal at a press conference on Monday.
It is further good news for manager Zinedine Zidane who has seen Lucas Vazquez, Luka Modric, and Toni Kroos all extend their contracts recently.
QUIZ: Can you guess the year from these El Clasico photos?
Bale, 27, has been consistently linked with moves away from Spain, with Manchester United reportedly interested.
The club released a statement that read: "Real Madrid and Gareth Bale have agreed an extension to the player's contract, keeping him at the club until the 30th of June 2022.
"Tomorrow, Monday at 1:30pm, Gareth Bale will appear at a press conference in the media room at the Santiago Bernabeu."
It once appeared Gareth Bale would return to the Premier League as a flop, barely a season after moving from London to Madrid. Burdened by the strapline of ‘world’s most expensive player’, the Welshman struggled to impose himself in a Ronaldo-dominated setup.
But he’s since adapted superbly and was arguably Real Madrid’s most important player in their run to La Undecima (an 11th Champions League crown) last season. Time will inevitably catch up with Ronaldo – although judging by his hat-trick against Alaves, that it still a little way away – and Bale is an ideal, and less demanding, talisman to take Real Madrid forward into their next decade.
Like Real Madrid?
Get more at www.madridistanews.com
Valencia hold Atletico in thrilling Liga draw
VOTE: Who should Real Madrid sign to replace Ronaldo?