The drainage of a viscous gravity current into a deep porous medium driven by both the gravitational and capillary forces is considered in two steps. We first study the one-dimensional case where a layer of fluid drains vertically into an infinitely deep porous medium. We determine a transition from the capillary-driven regime to the gravity-driven regime as time proceeds. Second, we solve the coupled spreading and drainage problem. There are no self-similar solutions of the problem for the entire time period, so asymptotic analyses are developed for the height, depth and front location in both the early-time and the late-time periods. In addition, we present numerical results of the governing partial differential equations, which agree well with the self-similar solutions in the appropriate asymptotic limits.