It looked like being a comfortable afternoon when Adam McGurk fired them ahead in the opening stages.
But Kristian Dennis took advantage of some sloppy defending to bring the non-league side level soon after.
The Blues created plenty of chances and the winner arrived in first half stoppage-time, with McGurk again on target.
Paul Cook made one enforced change from the side beaten at Notts County in the league the previous week.
With Caolan Lavery not given permission to play by parent club Sheffield Wednesday, Conor Chaplin came in to lead the line.
That meant that recent loan arrival Marc McNulty had to be content with a place among the substitutes.
Before kick-off there was a minute’s silence in memory of former Pompey player and manager Bobby Campbell – who sadly passed away on Friday – as well as all those who have lost their lives in service of their country.
When the game got started it was the hosts – attacking the Fratton End in the first half – who looked more dangerous.
And they broke the deadlock after just three minutes when McGURK collected a fine pass from Kyle Bennett and fired home off the inside of the post.
Brian Murphy got down low to keep out Paul Turnbull’s long-range effort soon after, but most of the action was taking place at the other end of the pitch.
A dangerous cross from Ben Davies had to be cleared behind, while Adam Webster’s header from the resulting corner was comfortably saved by Shwan Jalal.
Chaplin then saw a shot swerve wide before Macclesfield levelled the tie in farcical fashion on 15 minutes.
Murphy took too long to clear when Enda Stevens threw the ball back to him, allowing Dennis to charge him down with the ball ricocheting into the net.
Pompey immediately set about trying to restore their advantage and Gareth Evans’ drive was punched clear by Jalal.
Murphy then atoned for his earlier error with an acrobatic save to deny Danny Whitehead from distance.
The Blues dominated the rest of the first half, however, and Chaplin drilled wide before Andy Halls made a vital interception to stop an unmarked McGurk collecting the ball inside the area.
David Fitzpatrick was then forced to clear Evans’ shot from the line after fine work from Bennett and McGurk down the left.
Pompey continued to pour forward and there were several more half chances as the clock ticked down on the first half.
But they did manage to forge ahead in stoppage-time when Stevens’ cross caused an almighty scramble in the Macclesfield box and McGURK kept his composure to stab home.
Macclesfield Town 1
It was the visitors who looked more eager immediately after the interval and Murphy had to be alert to keep out Danny Whitaker’s effort.
Stevens’ clearance then ricocheted off Michael Doyle and fell kindly for Dennis, but his shot flew over the bar.
Pompey carved open their first chance of the half on 56 minutes when Bennett and McGurk showed good perseverance to win possession and Chaplin’s shot was deflected narrowly wide.
Evans and Danny Hollands were unable to test Jalal from long-range as the hosts lacked the attacking threat that had been so evident before the break.
With that in mind, Cook made his first change on 66 minutes, handing McNulty his debut in place of Chaplin.
And a second switch soon followed as the inventive Bennett made way for Kal Naismith down the left.
McNulty looked lively, but was caught offside from Doyle’s pass and then there was no-one to meet his low centre.
The striker probably should have added a third goal on 83 minutes, only to head Evans’ pin-point cross over the bar.
And he then saw his fierce shot beaten away by Jalal after doing well to weave past a couple of challenges.
But it mattered not as the hosts comfortably held on for their first FA Cup win in five years to book their place in Monday night’s second round draw.
Pompey (4-2-3-1): Murphy; Davies, Burgess, Webster, Stevens; Hollands, Doyle (c); Evans, McGurk (Boco 90), Bennett (Naismith 69); Chaplin (McNulty 66)
Goals: McGurk 3, 45+1
Subs not used: Bass, Clarke, Atangana, Tollitt
Macclesfield (4-1-4-1): Jalal; Halls, Pilkington (Byrne 46), Diagne, Fitzpatrick; Turnbull (c) (Sampson 75); Holroyd, Whitehead (Lewis 75), Whitaker, Rowe; Dennis
Goals: Dennis 15
Subs not used: Branagan, Cowan, Churchman, Meikle
Referee: Lee Swabey
Attendance: 9,834 (411 away fans)