In a frenzied first period Dortmund came from a goal down to lead 5-2 with Shinji Kagawa scoring twice and Marco Reus, back from a six-month injury break, also on target along with Nuri Sahin and Ousmane Dembele.
Legia's Aleksandar Prijovic netted twice for the Poles and also hit the woodwork in a topsy-turvy first half.
Dortmund coach Thomas Tuchel fielded a largely second-string team following their win over Bayern Munich in the Bundesliga on Saturday, including top striker Pierre-Emerick Aubameyang.
Dortmund are top of Group F, two points ahead of Real Madrid, with their final group match in Spain in December.
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
(Reporting by Karolos Grohmann; editing by Ken Ferris)
