According to transfer journalist Fabrizio Romano, the new deal would run until June 2031 and include an improved salary, with personal terms almost fully agreed.
Gvardiol joined Manchester City from RB Leipzig in the summer of 2023 in a deal reported to be worth around €90 million.
Since then, the 24-year-old has become an important part of Pep Guardiola's defence, operating across both centre-back and left-back roles.
This season, Gvardiol scored two goals and provided two assists in 18 league appearances, 16 of them starts, for Manchester City.
His current contract runs until the summer of 2028, but City have been working on a renewal for some time as part of director of football Hugo Viana's priorities heading into the summer.
Real Madrid had been credited with strong interest in Gvardiol, with reports in Spain suggesting the Spanish giants had already made contact with the defender's representatives.
Barcelona were also reported to have entered the picture, tabling an offer in excess of €80 million plus bonuses for the centre-back.
Manchester City are understood to have blocked any approach as they focused on tying Gvardiol down to fresh terms.
"Manchester City are confident to get new contract sealed soon with Joško Gvardiol," Romano wrote.
"New deal to be valid until June 2031 with improved salary, City believe deal now almost agreed waiting for final green light. Real Madrid have been trying for weeks but City now optimistic."
The Athletic's Sam Lee had previously reported that Gvardiol was settled in Manchester and viewed as the cornerstone of the defence under incoming manager Enzo Maresca.
With Ruben Dias also expected to remain at the club, City look set to enter Maresca's first full season with their defensive core largely intact.
Nathan Ake is among those expected to leave the Etihad Stadium this summer as City continue to reshape the squad around their existing core.
For Real Madrid, the situation now leaves club president Florentino Perez needing to look elsewhere for defensive reinforcements, with names including Borussia Dortmund's Nico Schlotterbeck and Arsenal's Riccardo Calafiori mentioned as alternatives.
Gvardiol has 34 minutes shy of becoming an undisputed leader at City, and a new long-term deal would only strengthen that trajectory heading into the new campaign.