Western appeared destined to hand City their first defeat this campaign when in-form attacker Kahli Johnson scored in the 45th minute at Ironbark Fields.
But McNamara tapped home in the 83rd minute to earn City a point.
United's goal came in contentious circumstances at the end of an otherwise uneventful first half.
Catherine Zimmerman whipped a cross in for Johnson, who flicked the ball straight at City goalkeeper Malena Mieres.
But Mieres fumbled her save, with the ball ruled to have crossed the line before she caught it again.
.— Ninja A-League (@aleaguewomen) @wufcofficial score first against the league leaders in dramatic fashion! 😲Melbourne City goalkeeper Malena Mieres thought she saved Kahli Johnson's shot, but it goes down as a goal ⚽�📺 Watch #WUNvMCY live NOW on Paramount+ and 10 Play. pic.twitter.com/Cwvf6pEITvJanuary 17, 2025
Johnson is now level with Emily Gielnik, Fiona Worts and Laini Freier at the top of the golden boot standings.
City coach Michael Matricciani brought on star attacker Holly McNamara at half-time.
The Matilda sparked several decent moments without finding her cutting edge until the game's closing moments.
Johnson whipped another effort just wide of the near post in the 75th minute, then McNamara struck.
United's defence was brought undone when Lourdes Bosch burst down the right and cut the ball inside for McNamara to tap home her second goal since her return from a third ACL tear.
Holly McNamara keeps — Ninja A-League (@aleaguewomen) @MelbourneCity's unbeaten streak alive with just minutes left on the clock! 😲🔥The 21-year-old star equalises after being expertly set-up by Lourdes Bosch. 📺 Watch #WUNvMCY live now on Paramount+ and 10 Play. pic.twitter.com/1vkrMBAiHSJanuary 17, 2025
Chloe Logarzo clipped the crossbar from a corner in stoppage time while McNamara sprayed a late chance, with both teams forced to settle for a point.
City play Western Sydney away next Saturday while United host Perth on Tuesday night.