The teenage defender is recovering from knee surgery after breaking down last month.
However, Real moved quickly to extend and upgrade Martinez's contract to assure the youngster of his place in their plans.
"I am very happy and excited to renew my contract with this great club, the best in the world," he posted to social media. "Now, more eager than ever, I am ready for everything that is to come. Hala Madrid!"
With this renewal, Real improves all the conditions of the defender during his time as a youth player (until 2026) and protects him with a buyout clause of over €50m.
All this has been secured while waiting for him to be clear to sign the agreement o further extend his stay and give him a first-team contractual status once he turns 18 (in August 2025).