The nonlinear dynamics of the outflow driven by magnetic explosion on the surface of compact object is investigated through special relativistic magnetohydrodynamic simulations. We adopt, as an initial equilibrium state, a spherical stellar object embedded in the hydrostatic plasma which has a density ρ(r) ∝ r−α and is threaded by a dipole magnetic field. The injection of magnetic energy at the surface of compact star breaks the dynamical equilibrium and triggers two-component outflow. At the early evolutionary stage, the magnetic pressure increases rapidly in time around the stellar surface, initiating a magnetically driven outflow. Then it excites a strong forward shock, shock driven outflow. The expansion velocity of the magnetically driven outflow is characterized by the Alfvén velocity on the stellar surface, and follows a simple scaling relation υmag ∝ υA1/2. When the initial density profile declines steeply with radius, the strong shock is accelerated self-similarly to relativistic velocity ahead of the magnetically driven component. We find that the evolution of the strong forward shock can be described by a self-similar relation Γsh ∝ rsh, where Γsh is the Lorentz factor of the plasma measured at the shock surface rsh. It should be stressed that the pure hydrodynamic process is responsible for the acceleration of the shock driven outflow. Our two-component outflow model, which is the natural outcome of the magnetic explosion, would deepen the understanding of the magnetic active phenomena on various magnetized stellar objects.