Converting CO2 into fuel or chemical feedstock compounds could in principle reduce fossil fuel consumption and climate-changing CO2 emissions. One strategy aims for electrochemical conversions powered by electricity from renewable sources, but photochemical approaches driven by sunlight are also conceivable. 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 metals. 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 rare. 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 known, 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.