Born in Palmerston North, Hartley came from a motorsport family โ his father Brian raced in Formula Atlantic among other categories. He began karting at age six, following his brother Nelson, and moved into Formula First, Formula Ford, and then Formula Toyota New Zealand before relocating to Europe. In Formula Renault 2.0, Hartley developed quickly, winning the Eurocup Formula Renault 2.0 championship in his second year after taking three victories.
He made his Formula Three debut at the 2007 Masters of Formula 3 at Zandvoort, finishing fourth. In 2008, he raced in the British Formula 3 Championship for Carlin Motorsport, winning five times and finishing third overall, while also contesting rounds of the Formula Three Euroseries. He returned to the full F3 Euroseries in 2009, finishing eleventh despite missing rounds for Formula Renault 3.5 commitments.
From 2008 to 2010, Hartley held reserve and test driver roles for Red Bull Racing and Scuderia Toro Rosso as part of the Red Bull Junior Team, but was released midway through 2010 after not securing a race win in his Formula Renault 3.5 campaign alongside Daniel Ricciardo.
Unable to secure a competitive single-seater seat, Hartley transitioned to sportscar racing in 2012 with Murphy Prototypes in the European Le Mans Series, racing in the LMP2 class. He secured a podium on his FIA WEC guest debut at Spa-Francorchamps and then tackled Le Mans for the first time.
The pivotal move came ahead of 2014 when Porsche named him a factory driver to pilot the newly developed Porsche 919 Hybrid in the WEC's LMP1 class. After a challenging debut year, Hartley and teammates Mark Webber and Timo Bernhard claimed the 2015 FIA World Endurance Championship drivers' title, winning four consecutive races mid-season to secure the crown. He retained his seat for 2016, where Porsche again won the manufacturers' title though the crew finished fourth in the drivers' standings.
In 2017, Hartley partnered Bernhard and countryman Earl Bamber. The season delivered a breakthrough Le Mans victory: after losing 18 laps due to a failed hybrid harvesting motor, late failures for rival LMP1 cars allowed Hartley's No. 2 Porsche to take an improbable overall win. The crew went on to clinch both the drivers' and manufacturers' championships. Sportscar365 named Hartley driver of the year for 2017.
Hartley made his Formula One debut for Scuderia Toro Rosso at the 2017 United States Grand Prix, replacing Pierre Gasly for that round before being retained for the remainder of the season in place of Daniil Kvyat. He was confirmed as a full-time Toro Rosso driver for 2018 alongside Gasly. His best Formula One result was ninth place at the 2018 United States Grand Prix. He finished the 2018 season nineteenth in the standings and was not retained for 2019, replaced by Alexander Albon.
Hartley returned to the WEC in 2019, joining Toyota Gazoo Racing to replace two-time Formula One world champion Fernando Alonso in the No. 8 Toyota TS050 Hybrid, partnering Sebastien Buemi and Kazuki Nakajima. The crew won the 2020 24 Hours of Le Mans when the sister car retired, giving Hartley his second Le Mans victory and first for Toyota.
With the introduction of the Hypercar regulations in 2021, Hartley raced the Toyota GR010 Hybrid alongside Buemi and, from 2022, Ryo Hirakawa. The 2022 season brought Hartley his third Le Mans victory, with the crew also winning at Fuji before clinching the drivers' championship at Bahrain. In 2023, Hartley and his teammates won the drivers' title again after a consistent season that included victories at Portimao and Fuji, while finishing second at Le Mans behind Ferrari.
The 2024 and 2025 seasons proved more challenging for Toyota overall, though Hartley contributed victories including a dramatic late-race win at Bahrain in 2024 that secured the manufacturers' championship for Toyota. At the 2026 Imola opener, Hartley and his teammates used strategic acumen to beat Ferrari at their home round, delivering Toyota its 50th WEC victory in its 100th start.
Hartley holds a joint-record four FIA World Endurance Championship drivers' titles, tied with Sebastien Buemi, and three 24 Hours of Le Mans victories (2017 with Porsche, 2020 and 2022 with Toyota). He is regarded as one of the foremost endurance racers of his generation, having succeeded at the top level with two of the sport's dominant manufacturers across different technical eras โ Porsche's LMP1 hybrid programme and Toyota's Hypercar campaign. His route through Formula Three and junior formulae before finding his calling in long-distance sportscars is a notable career arc, and his two seasons in Formula One provided an additional dimension to a career defined by endurance racing excellence.