Dutchman Klaas-Jan Huntelaar completed the win, breaking a 71-year club record for the number of goals in a season, in a match between two sides knocked out of the Europa League on Thursday.
Huntelaar has scored 43 goals in 42 games, 24 in the Bundesliga, 10 in the Europa League, five in the German Cup and four in Europa League qualifiers.
New Leverkusen coach Sami Hyypia was in charge for the first time and recalled former Germany captain Michael Ballack.
Croat Mladen Petric gave Hamburg the lead with a penalty just before halftime. Andre Schuerrle levelled for Leverkusen, heading in after the ball took several ricochets in the penalty area.
Schalke stayed third, which would be enough to take them to the group stage of the Champions League next season, and opened a five-point gap over fourth-placed Borussia Moenchengladbach.
Huub Stevens's Schalke have 57 points from 29 games, six behind second-placed Bayern Munich and a further three adrift of leaders Borussia Dortmund. Hanover are eighth on 41 points.
Hamburg occupy 14th spot in the 18-team table with 31 points, only two clear of Cologne who are in the relegation playoff spot.
Hertha Berlin have 27 points and Kaiserslautern are on 20.
Schalke, eliminated from the Europa League by Athletic Bilbao, were given an early boost when former Real Madrid and Spain forward Raul rose at the near post to head in Jefferson Farfan's free kick in the sixth minute.
Farfan, who also had a hand in the other two goals, smashed a ball against the post soon after as the Royal Blues dominated against Hanover who were knocked out of the Europa League by Atletico Madrid.
The highlight came two minutes after halftime when Peru forward Farfan laid the ball off for Raul on the edge of the penalty area.
The 34-year-old took the ball past one defender, then left goalkeeper Ron-Robert Zieler floundering with a cheeky dragback before slotting the ball into the net with his right foot.
It was his 14th Bundesliga goal of the season, his 20th in all competitions and his 39th since his surprise move to Gelsenkirchen at the start of last season.
Just after the hour Farfan broke down the right and pulled the ball back for Huntelaar who had an easy job to complete the scoring and break the record set by Herrmann Eppenhoff in 1940-41.
Hamburg, who have taken only five points from their last eight games, went ahead against Leverkusen when the ball struck Gonzalo Castro's elbow. The referee harshly judged it to be deliberate and Petric slotted home the penalty.
Leverkusen fought their way back after the break and levelled in the 55th minute following a corner.
Stefan Kiessling had a powerful header cleared off the line by Robert Tesche, the ball hit team mate Jeffrey Bruma and rebounded on to the bar and Schuerrle was on hand to head in from point-blank range.
Former Liverpool and Finland defender Hyypia, who ended his playing career at Leverkusen last season, took over as coach following Robin Dutt's departure last week.
Given the job until the end of the season, he brought back Ballack who had been out since injuring his calf in February.