  Relativistic jets naturally occur in astrophysical systems that involve
accretion onto compact objects, such as core collapse of massive stars in
gamma-ray bursts (GRBs) and accretion onto supermassive black holes in active
galactic nuclei (AGN). It is generally accepted that these jets are powered
electromagnetically, by the magnetised rotation of a central compact object.
However, how they produce the observed emission and survive the propagation for
many orders of magnitude in distance without being disrupted by current-driven
non-axisymmetric instabilities is the subject of active debate. We carry out
time-dependent 3D relativistic magnetohydrodynamic simulations of relativistic,
Poynting flux dominated jets. The jets are launched self-consistently by the
rotation of a strongly magnetised central compact object. This determines the
natural degree of azimuthal magnetic field winding, a crucial factor that
controls jet stability. We find that the jets are susceptible to two types of
instability: (i) a global, external kink mode that grows on long time scales
and causes the jets to bodily bend sideways. Whereas this mode does not cause
jet disruption over the simulated distances, it substantially reduces jet
propagation speed. We show, via an analytic model, that the growth of the
external kink mode depends on the slope of the ambient medium density profile.
In flat density distributions characteristic of galactic cores, an AGN jet may
stall, whereas in stellar envelopes the external kink weakens as the jet
propagates outward; (ii) a local, internal kink mode that grows over short time
scales and causes small-angle magnetic reconnection and conversion of about
half of jet electromagnetic energy flux into heat. Based on the robustness and
energetics of the internal kink mode, we suggest that this instability is the
main dissipation mechanism responsible for powering GRB prompt emission.
