Bayer Leverkusen battled back to claim the final Champions League spot with a 2-1 victory over Werder Bremen on the final day of the Bundesliga season.