Leckie headed his side ahead in the 26th minute, with Davie Selke restoring the visitors' lead immediately after Aritz Aduriz had equalised with a 35th-minute penalty.
Aduriz netted from the penalty spot for the second time on 66 minutes, with Inaki Williams scoring what proved to be the winner eight minutes from time.
The result leaves Athletic in second place in the group on eight points, two behind leaders Ostersunds with one game to play, while Leckie's Hertha are bottom on four points and unable to progress to the knockout stage.