We report two-dimensional simulations of drop dynamics on a substrate subject to a wetting gradient and an external pressure gradient along the substrate. A phase-field formulation is used to represent the drop interface, and the moving contact line is modelled by Cahn–Hilliard diffusion. The Navier–Stokes–Cahn–Hilliard equations are solved by finite elements on an adaptively refined unstructured grid. For a single drop and a pair of drops, we consider three scenarios of drop motion driven by the wetting gradient only, by the external flow only, and by a combination of the two. Both the capillary force and the hydrodynamic drag depend strongly on the shape of the drop. Since the drop adapts its shape to the local wetting angles and to the external flow on a finite time scale, hysteresis is a prominent feature of the drop dynamics under opposing forces. For each wetting gradient, there is a narrow range of the magnitude of the external flow within which a single drop can achieve a stationary state. The equilibrium drop shape and position depend on its initial shape and the history of forcing. For a pair of drops, the wetting gradient or external flow alone tends to produce catch-up and coalescence. The flow-driven coalescence arises from a viscous shielding effect that relies on the asymmetric shape of the trailing drop once it is deformed by flow. This mechanism operates at zero Reynolds number, but is much enhanced by inertia. With the two forces opposing each other, the external flow favours separation while the wetting gradient favours coalescence. The outcome depends on their competition.