The 16-year-old forward, widely regarded as one of the brightest prospects in English football, thanked United for helping him develop after joining their academy in 2020 as a 10-year-old.
"Dear Manchester United, I arrived in 2020 as a 10-year-old boy with big dreams," Gabriel wrote in an Instagram video documenting his time at the club.
"Here I grew as a player and a person. From scoring at Old Trafford to receiving the Jimmy Murphy Award, you gave me moments I'll always treasure.
"To every coach, every member of staff, to my team-mates and everyone who supported me, thank you for believing in me and helping me grow.
"As I begin my next chapter, Manchester United will always be a part of my story. Thank you for everything. JJ."
The teenager made a senior appearance for United during pre-season, featuring against AC Milan and Atletico Madrid, but never played in a competitive first-team fixture.
His departure represents a significant loss for United, with Gabriel having enjoyed an impressive spell at youth level. He was named Premier League Under-18 Player of the Year last season, collected the club's Under-18 Player of the Year award and finished as top scorer in a team that reached the FA Youth Cup and Premier League Under-18 Cup finals.
Real Madrid are understood to appeal to Gabriel and his representatives because they believe there is a clear route into the first team at the Santiago Bernabeu.
The forward has previously outlined his ambitions, telling Spanish newspaper Marca that his dream is to win the Ballon d'Or.