Hartley was a surprise inclusion in the #911 Porsche alongside Swiss driver Daniel Allemann and Germans Ralf Bohn, Robert Renauer and Alfred Renauer
The #12 Manthey Porsche 991 GT3 R of Sven Muller, Matteo Cairoli and Jochen Krumbach was second after turning 576 laps, two down on the winning machine.
Hampered with a power steering problem the #3 Black Falcon Mercedes AMG GT3 of Maro Engel, Abulaziz Al Faisal, Hubert Haupt, Yelmer Buurman and Michal Broniszewski were third, three laps down.
Hartley, who is favourite to win the World Endurance Championship this season alongside fellow Kiwi Earl Bamber and Timo Bernhard, was beaming after the victory.
“Awesome experience. First time in a GT car, first time in a 911 and first win in a 24 Hour race. Hopefully that form carries onto the WEC,” Hartley, the 2015 WEC champion, said.
“Very cool and very happy to be a part of it.”
The Optimum Motorsport Audi R8 LMS was fourth ahead of the Imsa Performance 991 GT3 R with the Belgian Audi Club WRT R8 LMS in sixth.
First home in the A6-Am class was the Hofor Mercedes AMG GT3 of Michael Kroll, Chantal Kroll, Roland Eggimann, Kenneth Heyer and Christiaan Frankenhout which was classified in seventh outright.
The #2 Black Falcon Mercedes crashed out at daybreak in the 17th Hour with Khaled Al Qubaisi at the wheel which also took out the #963 Lamborghini Huracan of Mirko Bortolotti.
In the second hour a fire engulfed the #7 HB Racing Lamborghini with Andrea Amici fleeing the cockpit which brought out the second Code 60 of the race.