Black hole (BH) X-ray binaries (XRBs) are X-ray luminous binary systems comprising a BH accreting matter from a companion star. Understanding their origins sheds light on the still not well understood physics of BH formation. M33 X-7 hosts one of the most massive stellar-mass BH among all XRBs known to date, a 15.65M⊙ BH orbiting a 70M⊙ companion star in a 3.45 day orbit. The high masses of the two components and the tight orbit relative to the large H-rich stellar component challenge our understanding of the typically invoked BH-XRBs formation channels. The measured underluminosity of the optical component further complicates the picture. A solution to the evolutionary history of this system that can account for all its observed properties has yet to be presented, and here we propose the first scenario that is consistent with the complete set of current observational constraints. In our model, M33 X-7 started its life hosting a 85-99M ⊙ primary and a 28-32M⊙ companion in a Keplerian orbit of 2.8-3.1 days. In order to form a BH of 15.65M⊙, the initially most massive component transferred part of its envelope to the companion star and lost the rest in a strong stellar wind. During this dynamically stable mass transfer phase the companion accreted matter, to become the presently underluminous 70M⊙ star.