The 16-year-old forward, who has been touted as one of Brazil’s best upcoming talents, will join the European and Spanish champions in July 2024.
This is due to Fifa rules prohibiting players under the age of 18 from being transferred abroad.
Palmeiras and Real Madrid did not disclose the length of the contract but said Endrick will be visiting his new club’s facilities in Spain next week.
Endrick told the Palmeiras website: “I thank Palmeiras, forever the club of my heart, for offering me everything necessary to become what I am today, for helping me to accomplish several of the my dreams and for respecting my desire and that of my family to make another dream come true.
“Until I join Real Madrid, I will continue to dedicate myself as I have always dedicated myself to being able to offer Palmeiras even more on the field.”
Endrick is both the youngest player and goalscorer in Palmeiras’ history.
The Brazil under-17 international has scored three goals in seven Brazilian Serie A games this season.
The Brazilian club’s president Leila Pereira said: “We have completed the biggest negotiation in the history of Brazilian football.
“Real Madrid’s proposal is compatible with Endrick’s enormous talent and corresponds to the sporting and financial goals that we have established since the beginning of negotiations.”
Source: Modern Ghana