AC Milan have put an end to weeks of speculation over the future of young in-demand goalkeeper Gianluigi Donnarumma by agreeing a new four-year deal with the stopper.

The 18-year-old, who has already made 72 appearances for Milan, was close to an exit after the club revealed that they had been informed by the player's agent Mino Raiola that he will not sign an extension to his current deal which was set to expire in 2018.

Donnarumma, who is widely regarded as the best young goalkeeper in football at the moment, had attracted interest from Manchester United and Real Madrid and it was expected that he will leave the Italian giants this summer. The Italy international seems to have performed a u-turn and agreed a new deal that will see him remain at the club at least until the summer of 2021.

"AC Milan and Gianluigi Donnarumma have reached an agreement to extend the goalkeeper's contract through to 2021," a statement read on the club's official site.

"Positive news for AC Milan, who have worked hard to renew the keeper's contract. Therefore, Gigio's experience in the Red and Black continues. AC Milan will be holding tight on one of the most talented players in the squad," the statement added.

Jose Mourinho had identified Donnarumma as a potential long-term replacement for David de Gea, who is continually linked with a move to Real. The Red Devils also have a strong relationship with the stopper's agent, whose three players – Henrikh Mkhitaryan, Paul Pogba and newly signed Romelu Lukaku – play at Old Trafford.

However, Milan manager Vincenzo Montella was delighted after the club secured the Italian goalkeeper's future. The Serie A outfit has been on a transfer spree this summer in a bid to return to the top of the league after struggling to mid-table finishes in recent seasons.

"It was a long soap opera, but the important thing was to reach the final result," Montella told, as quoted by Four Four Two. "Gigio is like a son to us, now he will need support so he can be focused and even better. Now he is to all intents and purposes a champion."

Gianluigi Donnarumma
Donnarumma has agreed a new contract with AC Milan after rejecting their initial offer Getty

"I am happy and think that this is the right choice for him too. Over the last few days the situation had taken this route."