Using special relativistic magnetohydrodynamic simulation, the nonlinear dynamics of the magnetized outflow triggered on the magnetar surface is investigated. It is found that the strong shock propagates in the circumstellar medium in association with the expanding outflow. The shock velocity vsh depends on the strength of the dipole field anchored to the stellar surface Bdipole and is described by a simple scaling relation vsh ∝ Bdipole0.5. In addition, the outflow-driven shock can be accelerated self-similarly to the relativistic velocity when the density profile of the circumstellar medium is steeper than the critical density profile, that is α ≡ d logρ(r)/d log r ≲ αcrit = −5.0, where the density is set as a power law distribution with an index α and r is the cylindrical radius. Our results suggest that the relativistic outflow would be driven by the flaring activity in a circumstellar medium with a steep density profile.