The Dons were profligate in the first half, with McGinn twice denied by Alan Mannus, before the Northern Irishman scored from a free-kick after 63 minutes.
McGinn's 11th of the season followed after 81 minutes as Aberdeen defied incessant horizontal rain to end a three-match winless run in the Scottish Premier League and climb to fourth, above Saints, who are without a win in four.
Aberdeen made a strong start as Saints played towards the worst of the elements.
Mannus saved a 25-yard shot from McGinn which swerved in the wind and then scrambled away the follow-up from Josh Magennis before the ball broke for Mitchel Megginson, whose effort deflected wide.
Mannus again saved from McGinn after the forward returned to his feet quickly following a good tackle by Frazer Wright as he shaped to shoot.
The Dons seemed certain to score when Megginson whipped the ball towards the far post, with Rory Fallon unmarked and poised to nod it in, but Russell Anderson hurled himself at the ball and headed wide as he finished up in the net.
Saints replaced Millar with Paddy Cregg in midfield after 28 minutes and six minutes later the visitors had an opportunity when Mackay's cross found Wright, who could not keep the ball down with the goal gaping.
Saints were again indebted to Mannus when he made a point-blank save from McGinn after meeting Magennis' cross from the left.
Magennis and Fallon had tame efforts as Saints were relieved to see the half end goalless.
In the second half, Liam Craig shot over for Saints after Anderson halted a run by Rowan Vine before Magennis won a free-kick at the other end in a dangerous position. From 25 yards out on the right, McGinn kept the ball low as he bent it around the wall into the bottom corner for his 10th of the season.
The Dons twice came close to doubling their lead in swift succession, only for Mannus to deny them on each occasion.
McGinn nodded down substitute Jamie Masson's cross for Magennis, who had the Saints goalkeeper at full stretch, before McGinn turned the ball goalwards and Mannus saved again.
Saints introduced Nigel Hasselbaink alongside fellow substitute Gregory Tade up front in an effort to find the equaliser, but immediately fell two behind.
Masson threaded the ball from the left through for McGinn to race through and place the ball low beyond Mannus and complete victory.