Using first-principles calculations within the generalized gradient approximation, we predicted the lattice parameters, elastic constants, vibrational properties, and electronic structure of cementite (Fe3C). Its nine single-crystal elastic constants were obtained by computing total energies or stresses as a function of applied strain. Furthermore, six of them were determined from the initial slopes of the calculated longitudinal and transverse acoustic phonon branches along the [100], [010] and [001] directions. The three methods agree well with each other, the calculated polycrystalline elastic moduli are also in good overall agreement with experiments. Our calculations indicate that Fe3C is mechanically stable. The experimentally observed high elastic anisotropy of Fe3C is also confirmed by our study. Based on electronic density of states and charge density distribution, the chemical bonding in Fe3C was analyzed and was found to exhibit a complex mixture of metallic, covalent, and ionic characters.