Rafa Benitez's side beat the League Two leaders Luton Town 3-1 thanks to two goals from Ayoze Perez and a strike from Jonjo Shelvey.
The third-round tie was watched by a remarkable crowd of 47,069, including 7,500 visiting fans, at St James's Park.
Benitez had named a strong team for the game, but he lost captain Jamaal Lascelles to injury with 31 minutes on the clock.
Lascelles – who limped off the field with a groin problem – will now be assessed ahead of the January 13 home Premier League game against Swansea City.
The game also saw goalkeeper Freddie Woodman make his long-awaited Newcastle debut.
United started well, though they had a let-off at the other end of the pitch when Woodman, under pressure, cleared the ball to a visiting player.
Newcastle's Jacob Murphy tested Luton goalkeeper Merk Stech with a 20-yard shot, and Perez also forced a save with a low shot.
The breakthrough came in the 31st minute when Stech spilled a free-kick from Gayle. Perez – who had netted United's winner against Stoke City on New Year's Day – was there to poke the ball home.
Lascelles, a key figure in Newcastle's recent Premier League revival, was then replaced by Isaac Hayden.
Perez netted his second of the game, and fourth of the season, five minutes later when Stech kept out a header from Gayle.
Shelvey swept the ball home from just inside the box before the break to make it 3-0 after a good move forward involving Perez and Gayle.
A spirited Luton side saw much more of the ball after the break.
Danny Hylton pulled a goal back for Nathan Jones' side in the 49th minute after rounding Woodman, who had raced off his line.
Hylton had another strike ruled out for offside, and they had United on the back foot for spells.
Visiting substitute Elliot Lee, son of former Newcastle midfielder Rob, hit the crossbar with a free-kick from outside the box.
Newcastle, however, held on to reach the fourth round.
NEWCASTLE UNITED: Woodman; Manquillo, Lascelles (Hayden, 31), Clark, Dummett; Ritchie, Shelvey (Diame, 71), Merino (Saivet, 81), Murphy; Perez, Gayle. Subs not used: Darlow, Aarons, Joselu, Haidara.
LUTON TOWN: Stech, Potts, Rea, Mullins, Justin, Ruddock (Cornick, 54), O Lee, Berry, Shinnie (Gambin, 82), Collins (E Lee, 68), Hytlon. Subs not used: Stacey, Cook, Shea, Famewo.
Goals: Perez 30, 36, Shelvey 39, Hylton 49
Bookings: Hylton 29, Dummett 59, Shelvey 62, Hayden 66
Referee: Neil Swarbrick (Preston)