The Portuguese manager will return to the Santiago Bernabeu 13 years after leaving the club, with his new deal running until June 30, 2029. He is expected to begin work on July 13 when Real Madrid start preparations for the new season.
Real Madrid announced the decision following a board meeting chaired by club president Florentino Perez.
A club statement said: "The Board of Directors of Real Madrid CF has agreed to appoint Jose Mourinho as first-team coach for the next three seasons, until June 30, 2029."
Mourinho previously spent three years in charge of Real Madrid between 2010 and 2013. During that period, he guided the club to a La Liga title with a record points total, while also winning the Copa del Rey and the Spanish Super Cup.
The 63-year-old returns to Madrid after a successful season with Benfica, where he led the Portuguese side through an unbeaten league campaign.
His appointment was made possible after the departure of Alvaro Arbeloa earlier this week, clearing the way for Real Madrid to finalise the move.
Benfica quickly confirmed Mourinho's exit and announced former Fulham manager Marco Silva as his replacement.
Mourinho had originally been expected to begin his second spell in Madrid shortly after the club's final La Liga match of the season against Athletic Bilbao. However, the process was delayed by Real Madrid's presidential election, which concluded on Sunday with Perez securing another term as president.
With that matter resolved, Real Madrid moved swiftly to bring back one of the most successful managers in the club's modern history as Mourinho prepares for a new chapter at the Bernabeu.