The crystal structure of NaMgF3 perovskite (neighborite) has been studied at 4 GPa and temperatures up to 1000 °C using the Rietveld structure-refinement method. In situ synchrotron X-ray powder diffraction data was collected using monochromatic radiation. The orthorhombic (Pbnm) to cubic (Pm3̅m) transition was observed when the temperature increased from 900 to 1000 °C. Structure refinements show that the ratio of polyhedral volumes of the A and B sites (VA/VB) of the orthorhombic phase increases with temperature, approaching the ideal value (5) for the cubic structure. However, this ratio becomes smaller at 4 GPa compared to the result from previous studies at the same temperature but ambient pressure, indicating that pressure makes it more difficult to transform from the orthorhombic phase to the cubic phase in this kind of perovskite.