Background Functional imaging studies have associated dystonia with abnormal activation in motor and sensory brain regions. Commonly used techniques such as functional magnetic resonance imaging impose physical constraints, limiting the experimental paradigms. Functional near-infrared spectroscopy (fNIRS) offers a new noninvasive possibility for investigating cortical areas and the neural correlates of complex motor behaviors in unconstrained settings. Methods We compared the cortical brain activation of patients with focal upper-limb dystonia and controls during the writing task under naturalistic conditions using fNIRS. The primary motor cortex (M1), the primary somatosensory cortex (S1), and the supplementary motor area were chosen as regions of interest (ROIs) to assess differences in changes in both oxyhemoglobin (oxy-Hb) and deoxyhemoglobin (deoxy-Hb) between groups. Results Group average activation maps revealed an expected pattern of contralateral recruitment of motor and somatosensory cortices in the control group and a more bilateral pattern of activation in the dystonia group. Between-group comparisons focused on specific ROIs revealed an increased activation of the contralateral M1 and S1 cortices and also of the ipsilateral M1 cortex in patients. Conclusions Overactivity of contralateral M1 and S1 in dystonia suggest a reduced specificity of the task-related cortical areas, whereas ipsilateral activation possibly indicates a primary disorder of the motor cortex or an endophenotypic pattern. To our knowledge, this is the first study using fNIRS to assess cortical activity in dystonia during the writing task under natural settings, outlining the potential of this technique for monitoring sensory and motor retraining in dystonia rehabilitation.