United's 17-year-old forward Ryan Gauld, starting for the first time, took only 23 minutes to make an impact when he raced on to a Mark Millar pass to knock the ball past Saints goalkeeper Alan Mannus.
With 12 minutes remaining United midfielder Stuart Armstrong was sent off by referee Iain Brines when he picked up a yellow card for simulation inside the Saints box, after being booked early in the game for a challenge on Gregory Tade.
Saints missed several chances in the final minutes as they pushed the 10-man visitors back but in the third minute of added time, Craig leapt to head in a corner from substitute Mehdi Abeid, who had replaced Tom Scobbie.
McNamara said: "You think it is going to be your night, you think you are going to win but you have to see it out. We defended well at times when they put us under pressure.
"The sending-off gave them the lift they needed. We stopped passing the ball and we got caught in a scrappy game."
On Armstrong's dismissal the Tannadice manager said: "I don't know if there was contact or not. I haven't asked Stuart yet. But you are looking for consistency.
"The lad who scores their goal, runs off the park into the crowd, and he had been booked, and nothing happens. Not that we could make too much of it in the last seconds but a lot of decisions there didn't go both ways."
United are in eighth place with 41 points and with one game against Aberdeen remaining before the split, have to wait and see if they can make the top half of the table.