The 19-year-old has broken into the Newcastle first team this season, making three substitute appearances in the top flight thus far.
Anderson made his Premier League debut against Arsenal in the 2020/2021 season and spent the second half of last season on loan at Bristol Rovers, helping them gain promotion from League Two to League One.
Newcastle, aware of Anderson's talents, rebuffed a number of offers to take him on loan again this term and integrated him into the first team.
Anderson has played youth football for both Scotland and England.
Upon signing his new deal, Anderson told the club's website: "I'm really happy. I love playing for Newcastle United, and committing my future to the club is something I've really wanted to do.
"It was my aim coming back into pre-season to work hard and earn the opportunity to stick around. I have really enjoyed being with the first team group, so hopefully I can keep improving and contribute to the team."
Newcastle manager Eddie Howe added: "We are all delighted with Elliot's development. He is a natural talent, but he also has an excellent work ethic and always wants to learn.
"I know our supporters will be especially pleased to see another local boy coming through from the Academy into the first team. Elliot has earned that chance, and he has set a great example to our young players.
"He is just at the start of his journey at this level but he has a very exciting future ahead and we are delighted that his journey will continue here."