Cytochrome P450 17A1 (also known as CYP17A1 and cytochrome P450c17) catalyses the biosynthesis of androgens in humans. As prostate cancer cells proliferate in response to androgen steroids, CYP17A1 inhibition is a new strategy to prevent androgen synthesis and treat lethal metastatic castration-resistant prostate cancer, but drug development has been hampered by lack of information regarding the structure of CYP17A1. Here we report X-ray crystal structures of CYP17A1, which were obtained in the presence of either abiraterone, a first-in-class steroidal inhibitor recently approved by the US Food and Drug Administration for late-stage prostate cancer, or TOK-001, an inhibitor that is currently undergoing clinical trials. Both of these inhibitors bind the haem iron, forming a 60° angle above the haem plane and packing against the central I helix with the 3β-OH interacting with aspargine 202 in the F helix. Notably, this binding mode differs substantially from those that are predicted by homology models and from steroids in other cytochrome P450 enzymes with known structures, and some features of this binding mode are more similar to steroid receptors. Whereas the overall structure of CYP17A1 provides a rationale for understanding many mutations that are found in patients with steroidogenic diseases, the active site reveals multiple steric and hydrogen bonding features that will facilitate a better understanding of the enzyme's dual hydroxylase and lyase catalytic capabilities and assist in rational drug design. Specifically, structure-based design is expected to aid development of inhibitors that bind only CYP17A1 and solely inhibit its androgen-generating lyase activity to improve treatment of prostate and other hormone-responsive cancers.