Protein phosphatases are involved in embryonic development, metabolic homeostasis, stress response, cell cycle transitions, and many other essential biological mechanisms. Unlike kinases, protein phosphatases remain understudied and less characterized. Traditional genetic and biochemical methods have contributed significantly to our understanding; however, these methodologies lack precise and acute spatiotemporal control. Here, we report the development of a light-activated protein phosphatase, the dual specificity phosphatase 6 (DUSP6 or MKP3). Through genetic code expansion, MKP3 is placed under optical control via two different approaches: (i) incorporation of a caged cysteine into the active site for controlling catalytic activity and (ii) incorporation of a caged lysine into the kinase interaction motif for controlling the protein-protein interaction between the phosphatase and its substrate. Both strategies are expected to be applicable to the engineering of a wide range of light-activated phosphatases. Applying the optogenetically controlled MKP3 in conjunction with live cell reporters, we discover that ERK nuclear translocation is regulated in a graded manner in response to increasing MKP3 activity.