The Swans made the stronger start and nearly took the lead through Ashley Williams.
The Dutch midfielder then tested Rob Elliot from around 20 yards, but the keeper managed to parry the ball away before it was hacked clear.
Gary Monk headed over from eight yards out just before half time, which came as a welcome relief for the Magpies.
The home side picked up where they had left off early in the second half, but still could not find the breakthrough.
As the game wore on, it was the visitors who began to threaten.
However, the hosts grabbed a deserved winner just five minutes from time as substitute Luke Moore scrambled the ball home.