Subthalamic nucleus deep brain stimulation is an effective treatment for advanced Parkinson's disease; however, its therapeutic mechanism is unclear. Previous modelling of functional MRI data has suggested that deep brain stimulation has modulatory effects on a number of basal ganglia pathways. This work uses an enhanced data collection protocol to collect rare functional MRI data in patients with subthalamic nucleus deep brain stimulation. Eleven patients with Parkinson's disease and subthalamic nucleus deep brain stimulation underwent functional MRI at rest and during a movement task; once with active deep brain stimulation, and once with deep brain stimulation switched off. Dynamic causal modelling and Bayesian model selection were first used to compare a series of plausible biophysical models of the cortico-basal ganglia circuit that could explain the functional MRI activity at rest in an attempt to reproduce and extend the findings from our previous work. General linear modelling of the movement task functional MRI data revealed deep brain stimulation-associated signal increases in the primary motor and cerebellar cortices. Given the significance of the cerebellum in voluntary movement, we then built a more complete model of the motor system by including cerebellar-basal ganglia interactions, and compared the modulatory effects deep brain stimulation had on different circuit components during the movement task and again using the resting state data. Consistent with previous results from our independent cohort, model comparison found that the rest data were best explained by deep brain stimulation-induced increased (effective) connectivity of the cortico-striatal, thalamo-cortical and direct pathway and reduced coupling of subthalamic nucleus afferent and efferent connections. No changes in cerebellar connectivity were identified at rest. In contrast, during the movement task, there was functional recruitment of subcortical-cerebellar pathways, which were additionally modulated by deep brain stimulation, as well as modulation of local (intrinsic) cortical and cerebellar circuits. This work provides in vivo evidence for the modulatory effects of subthalamic nucleus deep brain stimulation on effective connectivity within the cortico-basal ganglia loops at rest, as well as further modulations in the cortico-cerebellar motor system during voluntary movement. We propose that deep brain stimulation has both behaviour-independent effects on basal ganglia connectivity, as well as behaviour-dependent modulatory effects.