Geometric phases, generated by cyclic evolutions of quantum systems, offer an inspiring playground for advancing fundamental physics and technologies alike. The exotic statistics of anyons realized in physical systems can be interpreted as a topological version of geometric phases. However, non-Abelian statistics has not yet been demonstrated in the laboratory. Here, we use an all-optical quantum system that simulates the statistical evolution of Majorana fermions. As a result, we experimentally realize non-Abelian Berry phases with the topological characteristic that they are invariant under continuous deformations of their control parameters. We implement a universal set of Majorana-inspired gates by performing topological and nontopological evolutions and investigate their resilience against perturbative errors. Our photonic experiment, though not scalable, suggests the intriguing possibility of experimentally simulating Majorana statistics with scalable technologies.