Immiscible fluid-fluid displacement in partial wetting continues to challenge our microscopic and macroscopic descriptions. Here, we study the displacement of a viscous fluid by a less viscous fluid in a circular capillary tube in the partial wetting regime. In contrast with the classic results for complete wetting, we show that the presence of a moving contact line induces a wetting transition at a critical capillary number that is contact angle dependent. At small displacement rates, the fluid-fluid interface deforms slightly from its equilibrium state and moves downstream at a constant velocity, without changing its shape. As the displacement rate increases, however, a wetting transition occurs: the interface becomes unstable and forms a finger that advances along the axis of the tube, leaving the contact line behind, separated from the meniscus by a macroscopic film of the viscous fluid on the tube wall. We describe the dewetting of the entrained film, and show that it universally leads to bubble pinch-off, therefore demonstrating that the hydrodynamics of contact line motion generate bubbles in microfluidic devices, even in the absence of geometric constraints.