The association of GRB170817A with GW170817 has confirmed the long-standing hypothesis that binary neutron star (BNS) mergers are the progenitors of at least some short gamma-ray bursts (SGRBs). This connection has ushered in an era in which broadband observations of SGRBs, together with measurements of the time delay between the gravitational waves and the electromagnetic radiation, allow to probe the properties of the emitting outflow and its engine to an unprecedented detail. Since the structure of the radiating outflow is molded by the interaction of a relativistic jet with the binary ejecta, it is of paramount importance to study the system in a realistic setting. Here we present a three-dimensional hydrodynamic simulation of a relativistic jet propagating in the ejecta of a BNS merger, which were computed with a general relativistic magnetohydrodynamic simulation. We find that the jets centroid oscillates around the axis of the system, due to inhomogeneities encountered in the propagation. These oscillations allow the jet to find the path of least resistance and travel faster than an identical jet in smooth ejecta. In our setup the breakout time is ~0.6 sec, comparable to the expected central engine duration in SGRBs and possibly a non-negligible fraction of the total delay between the gravitational and gamma-ray signals. Our simulation also shows that energy is carried in roughly equal amounts by the jet and by the cocoon, and that about 20 per cent of the injected energy is transferred to the ejecta via mechanical work.