Rory Holden’s header five minutes before the break paved the way for a historic Conference League victory that ended in the last quarter after Branimir Kalajka dealt with a powerful strike from substitute Adam Wilson.
Declan McManus sent his 78th penalty through the center as Alexander Zarutsky dived down the right and there was no looking back for the visitors from Kazakhstan after that.
Croud Meadow in Shrewsbury hosted the big night of Welsh football, with UEFA rules preventing TNS from playing at their Oswestry home 20 miles away.
Astana made the marathon trip to Shropshire on Tuesday with a nine-hour flight to London and a three-hour bus journey to their base in Telford.
They had beaten Serbia’s TSC in that competition three weeks ago, but domestic matters were clearly on their minds with 11 players remaining at home ahead of Sunday’s Kazakhstan Premier League clash against Aktobe.
TNS – fresh from a record Welsh Cup 16-0 win over Llangollen – would have been boosted by the news they will face second-string Astana after losing their Conference League opener 2-0 to Fiorentina .
Conor Roberts excelled at the Stadio Artemio Franchi to keep Fiorentina out for 65 minutes but was almost beaten straight away when Ramazan Karimov’s shot ricocheted off the post.
Roberts’ strong arm denied Stanislav Basmanov a corner before TNS showed their ability to counter-attack.
McManus was able to get his finger on Holden’s waist and force a save from Zarutskiy.
Another slick TNS break ended with McManus meeting Jordan Williams’ cross, although he didn’t have the strength to trouble Zarutsky.
Astana failed to account for most of the possession as attacks broke down in the final third and their carelessness was punished before the break.
McManus kept the ball up well and Ryan Broble delivered a great pass down the left.
Williams was released into space and Holden – who has stepped onto the Football League boards at Rochdale, Barrow, Walsall and Port Vale – dispatched his eye-catching cross with a superb header.
TNS saw strong claims for a penalty disallowed two minutes later after Holden’s attempt was cleared off the line by Abzal Beisebekov.
Holden was sent off by Zarutski after making contact with the ball, but neither Estonian referee Juri Frischer nor VAR were interested in TNS’s appeals.
The only result was a booking for Craig Harrison for his touchline protest, but the TNS boss must have been delighted with the maturity of his side’s performance.
Zarutskiy’s double saves from Daniel Williams and McManus stopped TNS from extending their early lead.
Astana pressed for an equalizer and Nnamdi Ahanonu rattled the frame with Roberts’ touch proving vital, but their resistance was ended when McManus kept his cool from 12 yards.