In this work, we report on the epitaxial growth of multiferroic YMnO3 on GaN. Both materials are hexagonal with a nominal lattice mismatch of 4%, yet x-ray diffraction reveals an unexpected 30 degree rotation between the unit cells of YMnO3 and GaN that results in a much larger lattice mismatch (10%) compared to the unrotated case. Estimates based on first principles calculations show that the bonding energy gained from the rotated atomic arrangement compensates for the increase in strain energy due to the larger lattice mismatch. Understanding the energy competition between chemical bonding energy and strain energy provides insight into the heteroepitaxial growth mechanisms of complex oxide-semiconductor systems.