After being named official reserve driver for Red Bull and Toro Rosso in 2008, and testing twice for the latter, a move to British Formula 3 followed, where he finished third ahead of Sergio Perez and Marcus Ericsson.
Gasly will be racing in the Super Formula finale but is expected to return to action in Mexico; Hartley is believed to be a potential candidate for a 2018 seat with Porsche pulling out of the World Endurance Championship at the end of the year.
Should he compete in the race he will become New Zealand's first F1 driver since Mike Thackwell in 1984.
"The Austin track is one I really enjoy and one I have raced at recently".
However, he was released from Red Bull's young driver programme in July 2010 and while he completed a young driver test for Mercedes in 2012 and did simulator work for the Silver Arrows in 2013, he failed to secure a full-time return to F1.
"What an awesome feeling!" said Hartley, who will fill the seat temporarily vacated by France's Pierre Gasly.
Hartley says the years he missed out on F1 made him more determined to make this opportunity a reality. While never reaching his true potential in single-seaters, Hartley has excelled ever since.
But having won the Le Mans 24 Hour Race earlier this year and on the back of some unique circumstances at Toro Rosso out of the blue this opportunity presented itself.
He has also been linked to an Indycars drive alongside New Zealander and four-time series champion Scott Dixon at Chip Ganassi Racing.
"He is one of those who is so competitive in everything he did, he wanted to be a victor - and that is what has given him the drive to keep on going".
"He was always looking to go quicker and look what he has got now".
Hartley was crowned World Endurance Champion alongside former grand prix victor Mark Webber and Timo Bernhard in 2015 and leads this year's title race with three rounds remaining.
"He is a wonderful kid and It has been so good to associated with him over the years".
Hartley last tested for Red Bull-owned Toro Rosso in 2009 and has not driven an F1 auto since 2012.
"With all the racing experience accumulated over the years, we are convinced that he will do a fantastic job for us".