Danny Hylton replied early in the second half for Luton, who more than held their own against their Premier League opponents.
The Hatters, with just one defeat in their last 14 matches, went into the game full of confidence and were cheered on by 7,500 travelling fans at St James’ Park.
Unlike many other Premier League teams, Newcastle made just four changes for the third round tie, perhaps wary of becoming victim of an FA Cup giant killing.
Jacob Murphy had two early opportunities for the home side. First, his low shot deflected past the post before another curling effort was well saved by Marek Stech.
Newcastle took the lead on the half hour when Dwight Gayle’s free-kick was only parried by Stech and Perez tapped home from close range.
Six minutes later, Newcastle doubled their lead through the same combination. This time a header from Gayle was only pushed away from goal by Stech, allowing Perez to tap home from close range once more.
Newcastle suffered an injury blow midway through the first half when captain Jamaal Lascelles was forced off and replaced by Issac Hayden.
The tie was virtually put beyond doubt shortly before half time when Perez and Gayle combined well to set up Shelvey to fire home Newcastle’s third.
Luton pulled one back shortly after the restart when Hylton broke clear before rounding Woodman and slotting home.
Hylton thought he had pulled another goal back a few minutes later but his celebrations were cut short by the offside flag.
Elliott Lee – son of former Newcastle midfielder Rob – then hit the bar with a free-kick as Luton continued to press.
However, they failed to add to their tally as Rafael Benitez’s held on to reach round four.