Gabriel Heinze signed for Spanish giants Real Madrid on August 22, 2007 thus becoming the third Manchester United player to sign for the capital club after Ruud van Nistelrooy and David Beckham. Heinze penned a four-year deal at Real Madrid until the end of the 2010/11 season. Real Madrid paid around £8m to sign him from the Red Devils.

Real Madrid gave Gabriel Heinze his debut in a La Liga encounter with Villarreal on September 2, 2007 as a substitute for striker Raul Gonzalez. His first goal for Real Madrid came during the 3-1 league win over Sevilla on March 3, 2008. He finished the season with 20 appearances in the league as Real Madrid emerged champions.

In his second season as a Real Madrid player, Gabriel Heinze was played more in comparison to his debut season. However, Real Madrid finished the season without any trophy apart from the Spanish Super Cup.

Gabriel Heinze spent just two years out of his four-year deal at Real Madrid before he signed for Marseille in the French top flight for an undisclosed fee on July 30, 2009. At Marseille, Heinze reunited with Lucho Gonzalez. In his first season at Marseille, the defender scored a career-best four league goals in 27 games as Marseille ended the season as winners of the French Ligue 1 and the French League Cup. He started the French League Cup final on March 27, 2010 as Marseille beat Bordeaux to win a first major trophy since the 1993 Champions League triumph. The Argentine then scored the opening goal in a 3-1 home win over Rennes on May 5, 2010 which helped Marseille clinch the league title. Manager Didier Deschamps described the season as an extraordinary adventure.

Heinze spent one more season at Marseille before leaving in the summer of 2011.