In October 2017, Hartley was offered a drive in Formula One by Toro Rosso for the United States Grand Prix which was held in Austin. Hartley replaced Pierre Gasly, who was absent contesting the Super Formula Championship final. It was Hartley's F1 debut where he became the ninth New Zealander to race in Formula One.