Margetts' solitary strike in the first half was enough to secure a place in the first qualifying round for the Daniels after a hard-fought contest.
Both sides had decent spells during the preliminary round tie but it was Stamford who took the decisive chance and had the game management to dig in and secure their place in the next stage.
Spalding handed a first start to summer signing Josh Moreman who was among four changes to the starting line-up from the goalless midweek draw at Cambridge City as Elliot Sandy, Danny Draper and Jordan O'Brien returned.
There was also a first Stamford start for Charlie Coppola while Joe Burgess returned after missing the midweek win over Harborough Town.
The two teams had both made decent starts to their Northern Premier League Midlands Division campaigns and the opening exchanges were tight with clear-cut chances at a premium.
Cameron Johnson saw a dangerous cross safely gathered by home goalkeeper Michael Duggan before Moreman went close for the Tulips as he got his foot to a headed back pass which fell short but saw his effort go just wide.
Sandy saw a well-struck effort blocked by Sean Wright while Harry Vince also got a crucial challenge in to deny Danny Draper.
The deadlock was broken after 26 minutes when Jake Duffy's corner picked out James Blunden at the back post and his header hit the upright with Margetts on hand to turn home the rebound from close range.
Spalding had a great chance to equalise shortly after as Sandy saw his initial effort well saved by Ben Heath with the Stamford goalkeeper making a brave block to keep out the rebound.
Stamford started to get stronger as the first half wore on with Johnson firing over before Sam Cartwright made a vital tackle to prevent Jack Duffy breaking clear while Coppola was inches away from converting an astute cross from Jake Duffy.
Margetts had an instinctive shot early in the second half tipped away by Duggan who then had to be alert to race out and block Jack Duffy’s effort with Coppola being crowded out in the follow-up which was blocked.
Duggan was again down well to deny Margetts after a deft touch by Johnson before Spalding started a late offensive in a bid to earn a replay.
Substitute Toby Hilliard headed wide with James Clifton also going close from an Aaron Hart cross as the match headed into six minutes of injury-time.
And it needed a fine save from goalkeeper Heath to deny the Tulips late on as Archie Jones picked out substitute Stefan Broccoli with a fine pass and he weaved an opening, only for the Stamford custodian to turn away his goalbound effort at full stretch.
As Spalding pushed more men forward in search of an equaliser, Stamford could have added to their tally in the final minute but Duggan was equal to Michael Frew’s shot and it was just the one goal that separated the two sides on the final whistle.