Barnes struck on 63 and 70 minutes - either side of Ruben Dias' deflected equaliser - to lift the Magpies clear of relegation danger.
City began brightly but were repeatedly denied by Nick Pope, while their goalkeeper Gianluigi Donnarumma produced big saves of his own to keep out Nick Woltemade.
Both sides missed clear chances, including Erling Haaland firing wide early and Barnes failing to convert a driven Jacob Murphy cross.
After the break, Newcastle capitalised on their first coherent attack as Barnes finished a slick one-two with Bruno Guimaraes.
Dias levelled five minutes later from a corner, but Barnes restored the lead almost immediately, reacting quickest after Guimaraes' header hit the bar. A lengthy VAR check upheld the goal, and Newcastle survived late pressure to seal a famous win.
Guardiola felt his side performed well overall but were undone by missed chances and key moments.
"Tight game, chances and an entertaining game. But in the end they scored two goals and won. In general we were really good, we just could not finish," said Guardiola.
The Spanish tactician was seeing engaging in a passionate exchange of words with Newcastle captain Guimaraes at full-time. Amid reports of an argument, Guardiola has said it was quite the contrary - and that in fact he was praising the Magpies captain for his quality.
"I told him how good he is," said Guardiola simply.
Meanwhile, Howe praised his team's attitude and said the win should inject much-needed momentum into their season.
"It's been a long wait for a win against Pep.The heart, the endeavour, the attitude of the group pleased me today. It should give us a big lift in a tough Premier League season," said Howe.
He also highlighted Barnes' clinical edge and resilience.
"Harvey is an outstanding player, He could have scored four today, but he's never rattled by missing," concluded the Newcastle boss.