The visitors went two ahead through midfielder Stuart Armstrong and winger Gary Mackay-Steven but Accies were given a lifeline in the 57th minute when Jesus Garcia Tena scored with a free-kick with Ali Crawford equalising in the 71st minute to set up a storming finale.
The home side had the momentum but it was United who came out on top when skipper Sean Dillon headed in from a corner as Martin Canning's tenure as Accies' interim player-manager got off to a dramatic but ultimately losing start.
Asked if his side were title contenders, the United boss said: "Not at this moment, no.
"We aren't good enough away from home in terms of clean sheets.
"There are a lot of things we need to work on defensively first.
"We are the top scorers in the league, we scored three tonight and could have got a few more but on the other side we have to be more stingy at the back.
"Can we be title contenders one day? That remains to be seen but my goal is to get them to believe they can be.
"It's putting that across and making sure we don't concede.
"We have to be better and grind results out - and see games through."
McNamara added: "It was a great three points from a strange game.
"We were comfortable at 2-0 and could have been 3-0 up before they scored.
"There was nothing we could (do) about the first goal
It was a fantastic free-kick.
"Hamilton got their tails up and got a break of the ball off the ref for the second.
"I was happy with the way we responded when it went 2-2
We showed a bit of steel.
"There were some good moments in the game and we could have scored more."
Canning, promoted on Friday after Alex Neil left for Norwich, dropped himself for Garcia Tena, and stated that he "couldn't be more proud of the way the boys fought back".
The 33-year-old defender will have a think before he decides whether he should return for the Celtic game at the weekend.
He said: "Somebody asked me if you can enjoy it - you can enjoy the couple of seconds after you score.
"After that it's back to focusing on the game
It was certainly an interesting first match.
"It's a sore one to take to lose the way we did to a set-piece goal
That's not like us.
"I didn't play myself as it's been a big week for me personally and I've had a lot to deal with.
"I felt that Jesus Garcia Tena and Mikey Devlin would be fully focused on playing.
"I will have a think about the Celtic game on Sunday and talk it over with (assistant) Frank McAvoy."
Source : PA