The Slovakia international joined the Magpies, initially on loan, from Sparta Prague in January 2018, making his debut in a 1-0 win against Manchester United the following month.
He has been between the posts for Newcastle in every Premier League game since, keeping 17 clean sheets in 59 top flight appearances and winning the North East Football Writers' Association Player of the Year award for 2018.
"It is an amazing feeling," the 30-year-old told NUFC TV. "I have to say that it feels like time has flown. It's been almost two years and I've found great people here who I can call friends. I've enjoyed my time here and I'm very glad that I can stay here for another six years."
Head coach Steve Bruce added: "I'm really, really pleased that Martin has committed his future to the club.
"He's been absolutely fantastic since the day he arrived and he's a hugely important figure for us both on the pitch and in the dressing room.
"He's a massive part of our plans for the future, so it's great that he's agreed to stay with us for the next few years, and a fitting reward for his performances."
Martin's shots-faced so far this season...