The Croat earned his first ever victory over the 20-time grand slam victor, surviving a second set comeback to defeat Federer 7-6 (6), 3-6, 6-2 on the grass courts of the German city.
Nadal will keep hold of the top ranking until the end of Wimbledon, too, with Federer having to defend 2000 points. He has also been almost unstoppable on grass with 20 straight victories.
Borna Coric produced the most notable performance of his career to defeat Roger Federer in an absorbing three-set encounter and win the Gerry Weber Open title.
The opening set was masterclass in serving, as aces pinged off both their rackets and Coric saved the only breakpoint late in the set to force a tiebreaker.
The 21-year-old had lost twice to Federer, but pushed him hard in their last meeting at Indian Wells in March.
He was the first Croatian to reach the final at Halle and now holds two titles after winning in Marrakesh in 2017.
A tie-break was needed to separate the pair, with Federer setting up set two points with a deep forehand that Coric was unable to return.
Leading 5-3, Federer squared the match in the next game as Coric hit the net again.