Bayard is located in the southern foothills of the Pinos Altos Range and Mogollon Mountains in the southwestern portion of New Mexico and situated east of the Continental Divide at an elevation of approximately 5800 feet .