Ultracold gases in optical lattices are of great interest, because these systems bear great potential for applications in quantum simulations and quantum information processing, in particular when using particles with a long-range dipole-dipole interaction, such as polar molecules. Here we show the preparation of a quantum state with exactly one molecule at each site of an optical lattice. The molecules are produced from an atomic Mott insulator with a density profile chosen such that the central region of the gas contains two atoms per lattice site. A Feshbach resonance is used to associate the atom pairs to molecules. The remaining atoms can be removed with blast light. The technique does not rely on the molecule-molecule interaction properties and is therefore applicable to many systems.