The path-integral Monte Carlo method with a constant-pressure ensemble is used to study both translational and orientational transitions in the phase diagram of D{sub 2} and H{sub 2} up to megabar pressures. With an intermolecular interaction potential determined to agree with the experimental equation of state, a rotational order-disorder phase transition is observed. The phase line for this transition is in quantitative agreement with part of the phase diagram for both D{sub 2} and H{sub 2}. No structural phase transition, and no transitions to the D-A and H-A phases (phase III) are observed. We attribute this in part to the limitations of simulation cell size. {copyright} {ital 1997} {ital The American Physical Society}