After Scotland's 4-0 loss away to Russia last time out, manager Steve Clarke said his side had to make sure that result was "the very, very bottom of the lowest" for the Tartan Army.
McGinn ensured they ended a four-game run of losses in Group I before the break, after which the match became increasingly farcical due to Hampden Park's sodden pitch.
Lawrence Shankland netted his first international goal, debutant defender Stuart Findlay headed home a corner and substitute Stuart Armstrong hit a sweet free-kick to make the scoreline more emphatic.
Scotland had scored only once in their past four games but broke the deadlock in the 12th minute in driving Glasgow rain.
Ryan Christie cut inside on the right and curled the ball towards Aldo Simoncini's bottom-left corner, with McGinn applying a deft touch to make sure.
McGinn was gifted a second when Simoncini pushed a tame Scott McTominay shot into his path, then he secured the matchball moments before half-time by pouncing from close range.
Conditions became more difficult after the interval and when McTominay's long-range drive thudded against the crossbar in the 65th minute, ex-Queen's Park striker Shankland was on hand to tuck home the rebound on his old home ground.
Findlay then joined Shankland in opening his international account with a header from Christie's corner, while Armstrong's glorious set-piece goal helps give Clarke's side hope for the future.
What does it mean? Play-off platform for Scotland
Though their hopes of automatic qualification for Euro 2020 are over, Scotland can still reach the finals via the Nations League play-offs after topping their group. Clarke's side desperately needed a confidence boost and this result, albeit against the worst national team in the world according to FIFA's rankings, should provide some momentum.
Scotland can build around McGinn
It took McGinn until his 16th international appearance to score for Scotland, but he looks increasingly at home at this level, albeit San Marino are very weak opposition. McGinn has made a flying start to life in the Premier League with Aston Villa and has now netted seven times for club and country this season.
5 - John McGinn has scored what is just the fifth hat-trick by a Scotland player this century, and the first since James Forrest against Israel in November last year. Magic. pic.twitter.com/zkJoWz48aW— OptaJoe (@OptaJoe) October 13, 2019
Simoncini's bizarre error
Brought into the side after Simone Benedettini conceded nine times against Belgium on Thursday, Simoncini's mistake gave McGinn a tap-in for his second goal. McTominay's shot did not appear to be on target and the goalkeeper could not even blame the wet surface on this occasion.
Key Opta Facts:
- Scotland have won all eight of their meetings with San Marino by an aggregate score of 27-0, and all four at home by a combined 19-0 scoreline. This was the biggest of those eight victories.
- Scotland scored double the number of goals in this win over San Marino (six) than they had managed in their first five games under Steve Clarke combined before this (three).
- San Marino have conceded 43 goals across their eight 2020 European Championship qualifiers, seven more than in their 10 games in qualifying for the 2016 tournament (36).
- John McGinn scored what was just the fifth hat-trick by a Scotland player this century, and the first since James Forrest against Israel in November last year.
- McGinn became the first player to score a first-half hat-trick for Scotland since Lawrie Reilly against USA in a friendly in April 1952, 67 years and 166 days ago.
- Lawrence Shankland and Stuart Findlay have become the first players to score on their first international starts for Scotland since Ikechi Anya did so against North Macedonia in September 2013.
Scotland are away to Cyprus and at home to Kazakhstan when the group concludes next month. San Marino will try to salvage pride from another difficult campaign with a home double-header against Kazakhstan and Russia.