The phase-space dynamics of runaway electrons is studied, including the influence of loop voltage, radiation damping, and collisions. A theoretical model and a numerical algorithm for the runaway dynamics in phase space are developed. Instead of standard integrators, such as the Runge-Kutta method, a variational symplectic integrator is applied to simulate the long-term dynamics of a runaway electron. The variational symplectic integrator is able to globally bound the numerical error for arbitrary number of time-steps, and thus accurately track the runaway trajectory in phase space. Simulation results show that the circulating orbits of runaway electrons drift outward toward the wall, which is consistent with experimental observations. The physics of the outward drift is analyzed. It is found that the outward drift is caused by the imbalance between the increase of mechanical angular momentum and the input of toroidal angular momentum due to the parallel acceleration. An analytical expression of the outward drift velocity is derived. The knowledge of trajectory of runaway electrons in configuration space sheds light on how the electrons hit the first wall, and thus provides clues for possible remedies.