  Ground-state structure is found and pressure-induced phase transitions up to
210 kbar are studied in mercury titanate from first principles within the
density functional theory. It is established that the $R3c$ structure
experimentally observed in HgTiO$_3$ is metastable at ambient pressure. With
increasing the hydrostatic pressure, the ground-state structure changes
following the $R{\bar 3} \to R3c \to Pbnm$ sequence. It is shown that the
appearance of ferroelectricity in HgTiO$_3$ at $P = 0$ is associated with an
unstable phonon mode. Optical and elastic properties of different phases of
mercury titanate are calculated. The quasiparticle band gap calculated in the
\emph{GW} approximation ($E_g = 2.43$ eV) agrees with experimental data better
than the value obtained in the LDA approximation (1.49 eV). Analysis of the
thermodynamic stability explains why the synthesis of mercury titanate is
possible only at high pressures.
