Converting CO2 into fuel or chemical feedstock compounds could in principle reduce fossil fuel consumption and climate-changing CO2 emissions1, 2. One strategy aims for electrochemical conversions powered by electricity from renewable sources3, 4, 5, but photochemical approaches driven by sunlight are also conceivable6. A considerable challenge in both approaches is the development of efficient and selective catalysts, ideally based on cheap and Earth-abundant elements rather than expensive precious metals7. Of the molecular photo- and electrocatalysts reported, only a few catalysts are stable and selective for CO2 reduction; moreover, these catalysts produce primarily CO or HCOOH, and catalysts capable of generating even low to moderate yields of highly reduced hydrocarbons remain rare8, 9, 10, 11, 12, 13, 14, 15, 16, 17. Here we show that an iron tetraphenylporphyrin complex functionalized with trimethylammonio groups, which is the most efficient and selective molecular electro- catalyst for converting CO2 to CO known18, 19, 20, can also catalyse the eight-electron reduction of CO2 to methane upon visible light irradiation at ambient temperature and pressure. We find that the catalytic system, operated in an acetonitrile solution containing a photosensitizer and sacrificial electron donor, operates stably over several days. CO is the main product of the direct CO2 photoreduction reaction, but a two-pot procedure that first reduces CO2 and then reduces CO generates methane with a selectivity of up to 82 per cent and a quantum yield (light-to-product efficiency) of 0.18 per cent. However, we anticipate that the operating principles of our system may aid the development of other molecular catalysts for the production of solar fuels from CO2 under mild conditions.