Using time- and spatially-resolved Kerr microscopy, we directly measure the spatiotemporal evolution of photoexcited local spins of a two-dimensional electron gas in a modulation-doped GaAs/AlGaAs quantum well with a top gate electrode. The spatial pattern of spins after diffusion is controlled by a gate voltage that changes the strength of the spin–orbit interaction (SOI) field. By measuring the time dependence of spin distribution with an external magnetic field, we successfully observe a persistent spin helix state by tuning the gate voltage, and we obtain both Rashba and Dresselhauss SOI parameters separately.