The field of biocatalysis has advanced from harnessing natural enzymes to using directed evolution to obtain new biocatalysts with tailor-made functions1. Several tools have recently been developed to expand the natural enzymatic repertoire with abiotic reactions2,3. For example, artificial metalloenzymes, which combine the versatile reaction scope of transition metals with the beneficial catalytic features of enzymes, offer an attractive means to engineer new reactions. Three complementary strategies exist3: repurposing natural metalloenzymes for abiotic transformations2,4; in silico metalloenzyme (re-)design5,6,7; and incorporation of abiotic cofactors into proteins8,9,10,11. The third strategy offers the opportunity to design a wide variety of artificial metalloenzymes for non-natural reactions. However, many metal cofactors are inhibited by cellular components and therefore require purification of the scaffold protein12,13,14,15. This limits the throughput of genetic optimization schemes applied to artificial metalloenzymes and their applicability in vivo to expand natural metabolism. Here we report the compartmentalization and in vivo evolution of an artificial metalloenzyme for olefin metathesis, which represents an archetypal organometallic reaction16,17,18,19,20,21,22 without equivalent in nature. Building on previous work6 on an artificial metallohydrolase, we exploit the periplasm of Escherichia coli as a reaction compartment for the ‘metathase' because it offers an auspicious environment for artificial metalloenzymes, mainly owing to low concentrations of inhibitors such as glutathione, which has recently been identified as a major inhibitor15. This strategy facilitated the assembly of a functional metathase in vivo and its directed evolution with substantially increased throughput compared to conventional approaches that rely on purified protein variants. The evolved metathase compares favourably with commercial catalysts, shows activity for different metathesis substrates and can be further evolved in different directions by adjusting the workflow. Our results represent the systematic implementation and evolution of an artificial metalloenzyme that catalyses an abiotic reaction in vivo, with potential applications in, for example, non-natural metabolism.