John Bostock fired County ahead in the fourth minute of first-half stoppage time with a free kick.
Paul Mullin evened the score in the 50th and Jacob Mendy put Wrexham ahead in the 69th as Reynolds and McElhenney watched on at the Racecourse Ground.
Celebrations from the home fans were cut short, however, when Kyle Cameron equalised for the visitors in the 75th.
Lee struck three minutes later to put Wrexham on course for victory.
That was before Eoghan O’Connell was adjudged to handle in the box and County had the chance to level the score once again from the penalty spot.
But Foster, who only stepped out of retirement last month to join Wrexham on a short-term deal, proved the hero with his last-gasp save.
“I’m used to working under extreme pressure I think, but usually I have some kind of say in it,” Reynolds said.
“I have control over it. I have nothing here.