Recent years have seen tremendous progress in the field of cold and ultracold molecules. A central goal in the field is currently the realization of stable rovibronic ground-state molecular samples in the regime of quantum degeneracy, e.g. in the form of molecular Bose-Einstein condensates, molecular degenerate Fermi gases, or, when an optical lattice is present, molecular Mott-insulator phases. However, molecular samples are not readily cooled to the extremely low temperatures at which quantum degeneracy occurs. In particular, laser cooling, the ‘workhorse’ for the field of atomic quantum gases, is generally not applicable to molecular samples. Here we take an important step beyond previous work1 and provide details on the realization of an ultracold quantum gas of ground-state dimer molecules trapped in an optical lattice as recently reported in Ref. 2. We demonstrate full control over all internal and external quantum degrees of freedom for the ground-state molecules by deterministically preparing the molecules in a single quantum state, i.e. in a specific hyperfine sublevel of the rovibronic ground state, while the molecules are trapped in the motional ground state of the individual lattice wells. We circumvent the problem of cooling by associating weakly-bound molecules out of a zero-temperature atomic Mott-insulator state and by transferring these to the absolute ground state in a four-photon STIRAP process. Our preparation procedure directly leads to a long-lived, lattice-trapped molecular many-body state, which we expect to form the platform for many of the envisioned future experiments with molecular quantum gases, e.g. on precision molecular spectroscopy, quantum information science, and dipolar quantum systems.