Neutral atomic Bose condensates and degenerate Fermi gases have been used to realize important many-body phenomena in their most simple and essential forms, without many of the complexities usually associated with material systems. However, the charge neutrality of these systems presents an apparent limitation - a wide range of intriguing phenomena arise from the Lorentz force for charged particles in a magnetic field, such as the fractional quantum Hall states in two-dimensional electron systems. The limitation can be circumvented by exploiting the equivalence of the Lorentz force and the Coriolis force to create synthetic magnetic fields in rotating neutral systems. This was demonstrated by the appearance of quantized vortices in pioneering experiments on rotating quantum gases, a hallmark of superfluids or superconductors in a magnetic field. However, because of technical issues limiting the maximum rotation velocity, the metastable nature of the rotating state and the difficulty of applying stable rotating optical lattices, rotational approaches are not able to reach the large fields required for quantum Hall physics. Here, we experimentally realize an optically synthesized magnetic field for ultracold neutral atoms, made evident from the appearance of vortices in our Bose-Einstein condensate. Our approach uses a spatially-dependent optical coupling between internal states of the atoms, yielding a Berrys phase sufficient to create large synthetic magnetic fields, and is not subject to the limitations of rotating systems; with a suitable lattice configuration, it should be possible to reach the quantum Hall regime, potentially enabling studies of topological quantum computation.