Lewis Hamilton claimed a record-breaking fifth Hungarian Grand Prix win to take the lead in the championship race for the first time this season.