Control over all internal and external degrees of freedom of molecules at the level of single quantum states will enable a series of fundamental studies in physics and chemistry. In particular, samples of ground-state molecules at ultralow temperatures and high number densities will allow novel quantum-gas studies and future applications in quantum information science. However, high phase-space densities for molecular samples are not readily attainable as efficient cooling techniques such as laser cooling are lacking. Here we produce an ultracold and dense sample of molecules in a single hyperfine level of the rovibronic ground state with each molecule individually trapped in the motional ground state of an optical lattice well. Starting from a zero-temperature atomic Mott-insulator state with optimized double-site occupancy, weakly-bound dimer molecules are efficiently associated on a Feshbach resonance and subsequently transferred to the rovibronic ground state by a stimulated four-photon process with >50 % efficiency. The molecules are trapped in the lattice and have a lifetime of 8 s. Our results present a crucial step towards Bose-Einstein condensation of ground-state molecules and, when suitably generalized to polar heteronuclear molecules, the realization of dipolar quantum-gas phases in optical lattices.