McGinn netted 10 minutes into each half in front of 10,175 fans at Pittodrie to keep them in the race for the top half ahead of their trip to Dundee United next Saturday, after which the Clydesdale Bank Premier League splits in two and Brown steps down.
Brown's replacement, Derek McInnes, would have been impressed with Aberdeen's attacking play as he watched from the stand with wide men McGinn and Jonny Hayes causing problems for a fragile-looking Hearts defence.
Hearts created a number of first-half chances with John Sutton hitting the post but their only real positive after the break was the introduction of right-back Jamie Hamill for his first appearance since damaging a cruciate ligament almost a year ago.
Aberdeen had not scored against Hearts in nine games but Gavin Rae could have ended the goal drought in the second minute when Josh Magennis and Scott Vernon combined to set him up in space 16 yards out but he volleyed over.
Hearts, who had Callum Tapping in midfield in place of the injured Darren Barr, also had an early chance when Michael Ngoo found himself one-on-one with Jamie Langfield but the Aberdeen goalkeeper stood up well and blocked the shot.
Aberdeen fans had sat through more than 800 minutes of action since Derek Young scored their previous goal against Hearts in January 2010 but they made it look simple when the breakthrough came.
Rae's pass set Hayes free down the right and he ran towards goal before rolling the ball inside for McGinn to shoot into the empty net.
Hearts were getting exposed on their left side when full-back Kevin McHattie tucked inside to mark Magennis and Vernon came close with a deflected shot and a header.
But Langfield soon needed to be at full stretch to push away John Sutton's header after Dylan McGowan's cross.
Hayes' reverse pass almost put Magennis through but the ball hit his heel and he could not hit the target as he turned round to stab a shot.
Hearts were attacking better than they were defending and Sutton flicked McHattie's cross off the far post.
Aberdeen almost scored a carbon copy of their goal after Vernon turned and released Hayes but the offside flag was up by the time the Irishman crossed for Magennis to slot home.
The chances continued to flow. Magennis headed wide from a Hayes corner and missed a sitter just before the break when he blazed a bouncing ball over from 12 yards as Hearts looked for an offside flag.
Langfield made another good save in between when Mehdi Taouil's reverse pass set up Jamie Walker with the Aberdeen goalkeeper getting down well to stop the shot.
Magennis was again foiled by the offside flag after the break when he finished from just inside the box after being set up by McGinn's run and pass.
The Northern Ireland international soon took matters into his own hands when he cut in from the left, turned McGowan one way and the next and then curled the ball into the top corner from a tight angle.
The former Celtic player soon had a chance for a hat-trick after Hayes ran from his own half and crossed to the far post but his shot was blocked.
McGinn was then booked for simulation after going down under Danny Wilson's penalty-box challenge. The tackle looked clumsy and there appeared to be contact from a distance but referee Willie Collum immediately produced the card.
McGinn was booked for diving against Kilmarnock in February but television replays showed he had been taken down by Rugby Park goalkeeper Cammy Bell.
Hayes blocked Wilson's effort on the line following a corner but Hearts then looked a beaten team.
Magennis had another chance after a slip by Andy Webster but the angle proved too tight to beat Jamie MacDonald and the Dons suffered a late blow when Hayes limped off.
Aberdeen survived some late scares before Brown and assistant Archie Knox received a warm ovation as they made their way to the tunnel.
- Sports & Recreation
- Clydesdale Bank Premier League