Leverkusen has seven points and must hope for some help from United to have a chance of advancing when it plays in San Sebastian. Real has one point and is eliminated.
United quickly took control, with Rooney setting up Valencia for the lead. Shinji Kagawa won the ball in midfield, and passed to Ryan Giggs, who found Rooney on the left. His perfectly weighed cross landed at the far post for Valencia to tap in.
Rooney created the second with a free kick, almost from the same spot. Spahic, under pressure from Smalling, headed backward past goalkeeper Bernd Leno.
Rooney was in the thick of it again after a corner from Giggs was flicked into the box by Patrive Evra. Rooney prodded home, Leno blocked the effort but Evans was there to tap in from close range.
"It was all over after the third goal," Leverkusen's captain Simon Rolfes said.
United did not stop and a bad clearance allowed Kagawa to pass to Rooney, who chipped a cross to the far post for Smalling to easily steer home.
Giggs, approaching his 40th birthday, then sent a long ball into space and Nani used the outside of his foot to find the target for United's fifth as Leno mistimed his exit.
United produced one of the most convincing performances under new coach David Moyes, with his predecessor Sir Alex Ferguson looking pleased in the stands.