McGinn was on target once in either half to move Aberdeen up to seventh place with Hearts’ brief two-game unbeaten run coming to an end in an exciting game that saw them waste plenty of openings.
Hearts had the better of the opening exchanges with Danny Wilson heading over and David Ngoo denied by Jamie Langfield when he went one-on-one with the Aberdeen keeper.
Those wasted chances were all the more costly when the Dons took the lead on nine minutes, Jonny Hayes getting free down the right and crossing for McGinn to tap in from close range and end Aberdeen’s goal drought against Hearts that stretched back nine game.
John Sutton was denied an equaliser by a fine save from Langfield, and the big striker went even closer just before the half-hour when he reacted well to get to a Jamie Walker cross only to see his shot come back off the post.
Ngoo continued to be a threat for the home side but Langfield was equal to his efforts, with Sutton also left wondering what Hearts had to do to beat an inspired Aberdeen goalkeeper.
And they were caught again nine minutes into the second period as McGinn beat a couple of would-be tacklers before firing past Jamie MacDonald.
McGinn was furious when booked for diving, looking in vain for a penalty that could have given him a hat-trick, while Hearts continued to press only for Hayes to clear a Wilson shot off the line.
Josh Magennis, who earlier had a goal chalked off for offside, was denied by a fine save by MacDonald and Hearts started to look dispirited as the game headed into the final quarter.
They had two chances to grab a consolation in injury-time but the habit of failing to take their openings continued, with Kevin McHattie poking wide after a Langfield error and Ngoo again denied by the keeper whose clean sheet was confirmed seconds later.
The victory leaves Aberdeen behind Kilmarnock only on goal difference ahead of the final game before the split, although Killie have a game in hand and taken on St Mirren at home in midweek where victory would go a long way towards sealing sixth place.