The Mars flyby of C/2013 A1 (Siding Spring) represented a unique opportunity for imaging a long-period comet and resolving its nucleus and rotation state. Because of the small encounter distance and the high relative velocity, the goal of successfully observing C/2013 A1 from the Mars orbiting spacecraft posed strict accuracy requirements on the comet's ephemeris. These requirements were hard to meet, as comets are known for being highly unpredictable: astrometric observations can be significantly biased and nongravitational perturbations affect comet trajectories. Therefore, even prior to the encounter, we remeasured a couple of hundred astrometric images obtained with ground-based and Earth-orbiting telescopes. We also observed the comet with the Mars Reconnaissance Orbiter's High Resolution Imaging Science Experiment (HiRISE) camera on 2014 October 7. In particular, these HiRISE observations were decisive in securing the trajectory and revealed that out-of-plane nongravitational perturbations were larger than previously assumed. Though the resulting ephemeris predictions for the Mars encounter allowed observations of the comet from the Mars orbiting spacecraft, post-encounter observations show a discrepancy with the pre-encounter trajectory. We reconcile this discrepancy by employing the Rotating Jet Model, which is a higher fidelity model for cometary nongravitational perturbations and provides an estimate of C/2013 A1's spin pole (RA, DEC) = (63 °, 14 °) .