The Earth acts as a gigantic heat engine driven by the decay of radiogenic isotopes and slow cooling, which gives rise to plate tectonics, volcanoes and mountain building. Another key product is the geomagnetic field, generated in the liquid iron core by a dynamo running on heat released by cooling and freezing (as the solid inner core grows), and on chemical convection (due to light elements expelled from the liquid on freezing). The power supplied to the geodynamo, measured by the heat flux across the core-mantle boundary (CMB), places constraints on Earth's evolution. Estimates of CMB heat flux depend on properties of iron mixtures under the extreme pressure and temperature conditions in the core, most critically on the thermal and electrical conductivities. These quantities remain poorly known because of inherent experimental and theoretical difficulties. Here we use density functional theory to compute these conductivities in liquid iron mixtures at core conditions from first principles--unlike previous estimates, which relied on extrapolations. The mixtures of iron, oxygen, sulphur and silicon are taken from earlier work and fit the seismologically determined core density and inner-core boundary density jump. We find both conductivities to be two to three times higher than estimates in current use. The changes are so large that core thermal histories and power requirements need to be reassessed. New estimates indicate that the adiabatic heat flux is 15 to 16 terawatts at the CMB, higher than present estimates of CMB heat flux based on mantle convection; the top of the core must be thermally stratified and any convection in the upper core must be driven by chemical convection against the adverse thermal buoyancy or lateral variations in CMB heat flow. Power for the geodynamo is greatly restricted, and future models of mantle evolution will need to incorporate a high CMB heat flux and explain the recent formation of the inner core.