More on KentOnline
Two goals in five second-half minutes put Margate one game away from the first round proper of the FA Cup on Saturday.
An entertaining Kent derby went to form with higher-leave Margate progressing, but they were made to work all the way by a Herne Bay side who were the better team in the first 45 minutes.
An own goal from keeper Ben Hunter and Jordan Chiedozie's goal were enough for Steve Watt's men.
Margate sat seventh in the Bostik Premier with just one defeat in their opening eight games this season while Bay started the day ninth in the division below with five wins and three defeats in eight league games.
Both keepers were called into early action, Bay's Jack Steventon seeing his shot turned behind by Lenny Pidgeley and then Gate's Frannie Collin's free-kick was saved by Ben Hunter at the other end.
It was the visitors who looked the better team, however, limiting Margate to few chances while playing the better football on the new 3G pitch at Hartsdown Park.
Bay lined up with a 3-5-2 formation, striker Junior Aikhionbare proving a difficult opponent for Margate centre-back Liam Friend, who was replaced at half-time.
Nassim Dukali cut inside from the left for Bay but curled his right-foot shot wide of the upright as the visitors looked the better team.
Margate's best moment in the first half came on 33 minutes. Dave Martin played in Collin, who went past keeper Hunter 25 yards from goal before going to ground.
Referee Jacob Miles decided that Collin had dived, however, and booked the Margate striker instead of giving the hosts a free-kick and a potential red card for Hunter.
Bay finished the half on top and had a controversial decision go against them on the stroke of half-time.
Dukali burst forward into the penalty area before being upended by Tom Wynter and captain James Rogers. Ref Miles gave a free-kick instead of a penalty, booking one of the Margate players although it was unclear which one as they were both stood in front of him when he produced the yellow card!
Margate introduced Chris Sessegnon at half-time for Friend and the home side were certainly playing at a higher tempo in the second half. It helped nullify the forward threat of Dukali, who never got going after the break.
They went ahead on 53 minutes when Collin's left-wing corner was headed against the bar by striker Chiedozie. The same player then slammed the rebound against the post before the ball went in off the unfortunate Hunter.
It was game over five minutes later as Margate added a second goal. Sessegnon tackled Dukali before Collin was sent clear. He unselfishly squared the ball for Chiedozie to fire home from close range.
Margate were never really troubled after the break by a Bay side - a combination of the visitors losing their way and the hosts giving Bay no time to settle on the ball.
It was nearly 3-0 when Smith cut inside with 15 minutes left but Hunter turned his near-post shot behind.
Both sides went close in stoppage time, Connor Wilkins failing to connect with a cross for Bay before Margate substitute Matt Bodkin's shot was turned over at the other end.
Margate: Pidgeley, Wynter, Mills, Rogers, Friend (Sessegnon 46mins), Swift, Smith (Bodkin 89mins), Prescott, Chiedozie, Collin, Martin (Stannard 67mins). Subs not used: Lee, Brown, Bray, Crabbe.
Herne Bay: Hunter, Shafer (Catmull 82mins), Brown, Steventon, Richardson, Leonard (Wisson 82mins), Wilkins, Carlton (Trespaderne 90mins), Embery, Aikhionbare, Dukali. Subs not used: Rumbol, Faris, Mulrooney-Skinner, Kamara.
Attendance: 1,009.