The 19-year-old has made his first-team breakthrough at Newcastle under Eddie Howe this season, with three Premier League appearances off the bench.
Howe told the club's official website: "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."
Whitley Bay-born Anderson progressed through the Magpies' academy and made his first-team debut against Arsenal in the FA Cup in January 2021.
He spent the second half of last season on loan at Bristol Rovers, scoring seven goals in 21 appearances as the club won promotion to Sky Bet League One.
Anderson said: "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's sporting director, Dan Ashworth, added: "Our strategy is not just about who we can buy, it is also about who we have and how we nurture and develop our best young talent.
"It's crucial for the club and our Academy to provide a pathway for our young players and a belief that if they are good enough, they will get an opportunity to play."