The Crab pulsar and its nebula are among the most studied astrophysical systems, and constitute one of the most promising environments where high-energy processes and particle acceleration can be investigated. They are the only objects for which significant X-ray polarization was detected in the past. Here we present the Imaging X-ray Polarimetry Explorer (IXPE) observation of the Crab pulsar and nebula. The total pulsar pulsed emission in the [2–8] keV energy range is unpolarized. Significant polarization up to 15% is detected in the core of the main peak. The nebula has a total space integrated polarized degree of 20% and polarization angle of 145°. The polarized maps show a large variation in the local polarization, and regions with a polarized degree up to 45–50%. The polarization pattern suggests a predominantly toroidal magnetic field. Our findings for the pulsar are inconsistent with most inner magnetospheric models, and suggest emission is more likely to come from the wind region. For the nebula, the polarization map suggests a patchy distribution of turbulence, uncorrelated with the intensity, in contrast with simple expectations from numerical models.