Longstaff also had the first goalscoring opportunity of the evening after only five minutes when he picked up the ball on the edge of the area, only to fire his effort wide of the target.
It was Rafael Benitez's side who were applying all of the early pressure, and Joselu came close with a curling effort moments later before firing wide having got onto the end of a free kick in the 19th minute.
The hosts did manage to stem Newcastle's flow of chances at the first half wore on, though, and it wasn't until Longstaff's 42nd-minute opener that the Premier League side had another clear sight of goal, with the 20-year-old finishing off a team move just before the interval.
St Patrick's almost responded immediately with their best chance of the first half, but Simon Madden could not convert a cross moments after coming on as a sub, with his sliding effort going wide of the target.
A new-look Newcastle team emerged for the second half but were quickly on top once again, with Atsu seeing one effort deflected over before DeAndre Yedlin's long-range effort fizzed narrowly off target.
Dwight Gayle was the next to come close with a little over 20 minutes remaining when he latched on to Jonjo Shelvey's pass before cutting inside and curling his effort just beyond the top-right corner.
A mixture of last-ditch defending and poor finishing was keeping the score at 1-0, and Newcastle squandered another glorious chance to increase their advantage in the 77th minute when Yedlin blazed a follow-up effort over the crossbar after the initial shot had been blocked.
Moments later Adam Armstrong saw another effort blocked before testing goalkeeper Barry Murphy from the follow-up, and even when the defence could not come to the home side's rescue the woodwork did, with Kenedy seeing his effort cannon back off the crossbar.
The Chelsea loanee saw another shot brilliantly saved by Murphy just four minutes later as the relentless Newcastle pressure continued, and the Magpies finally got their second goal four minutes from time after Gayle had been brought down inside the box.
Atsu stepped up to take the spot kick and made no mistake from 12 yards, finally sealing the victory as Newcastle made a winning start to their pre-season campaign.