We study the energy levels of H 2 molecules in a superstrong magnetic field (Bտ10 12 G͒, typically found on the surfaces of neutron stars. The interatomic interaction potentials are calculated by a Hartree-Fock method with multiconfigurations assuming electrons are in the ground Landau state. Both the aligned configurations and arbitrary orientations of the molecular axis with respect to the magnetic-field axis are considered. Different types of molecular excitations are then studied: electronic excitations, aligned ͑along the magnetic axis͒ vibrational excitations, and transverse vibrational excitations ͑a constrained rotation of the molecular axis around the magnetic-field line͒. Similar results for the molecular ion H 2 ϩ are also obtained and compared with previous variational calculations. Both numerical results and analytical fitting formulas are given for a wide range of field strengths. In contrast to the zero-field case, it is found that the transverse vibrational excitation energies can be larger than the aligned vibration excitation, and they both can be comparable to or larger than the electronic excitations. For BտB crit ϭ4.23ϫ10 13 G, the Landau energy of the proton is appreciable and there is some controversy regarding the dissociation energy of H 2 . We show that H 2 is bound even for B ӷB crit and that neither proton has a Landau excitation in the ground molecular state.