Dislocation slip and twinning are equally important in the plastic deformation of hexagonal close packed crystals. Basal slip and extension 101¯2<1¯011> twins can be activated concurrently in magnesium and, as a result, complex dislocation-dislocation, twin-twin, and dislocation-twin interactions take place and determine the hardening behavior. Here, using atomistic simulations, we study the latter mechanism, namely, the interactions between basal <a> dislocations and a three-dimensional (3D) {101¯2} twin. According to our findings, a basal screw dislocation can fully transform into the twin via multiple cross-slip between basal and prismatic planes in the matrix. This process causes the formation of jogs and basal stacking faults in the matrix, and prismatic <a> dislocations in the twin. We also find that a basal mixed dislocation cannot directly transform into the twin. Instead, it dissociates into twinning dislocations, resulting in a change in twin thickness and the formation of basal/prismatic steps. When the dislocation interacts with the lateral twin boundary, slip transformation in the twin is accomplished through the gliding of either ½<a+c> or <a+c> on the prismatic plane in the twin. Accompanying the gliding of ½<a+c>, a prismatic stacking fault is created inside the twin. By accounting for the 3D character of the dislocation-twin reactions, our results extend our understanding of slip transformation into a twin, the formation of basal and prismatic stacking faults in matrix and twin, and the role that local stresses and the lateral boundary of the twin play in this process.