A method for forming a magnetic tunneling junction, MTJ, device, the method comprising: forming a layer stack comprising an MTJ layer structure and a spin-orbit torque layer, SOT-layer, below the MTJ layer structure; forming a first etch mask over the layer stack, the first etch mask comprising at least one first mask line extending in a first direction perpendicular to a stacking direction of the layer stack; patterning the layer stack to form at least one MTJ line extending in the first direction, the patterning comprising etching while the first etch mask masks the layer stack, and stopping etching on or above the SOT-layer; forming sidewall spacers on either side of each MTJ line; while the sidewall spacers mask the SOT-layer, etching the SOT-layer to form a patterned layer stack comprising the at least one MTJ line and a first patterned SOT-layer; forming a second etch mask over the patterned layer stack, the second etch mask comprising at least one second mask line extending across the at least one MTJ line in a second direction perpendicular to the stacking direction of the layer stack; and patterning the patterned layer stack comprising the first patterned SOT-layer and the at least one MTJ line to form a twice patterned SOT-layer, the twice patterned SOT-layer comprising at least one SOT-line extending in the second direction, and to form an MTJ pillar on each SOT-line, the patterning comprising etching while the second etch mask masks the patterned layer stack; wherein the layer stack is formed on an insulating layer embedding at least one terminal pair of a first and second terminal, the first and second terminals of each pair being spaced apart in the second direction and wherein the SOT-layer is formed in contact with the at least one terminal pair, and characterized in that the sidewall spacers on each respective MTJ line are formed to fully overlap the first and second terminals of a respective terminal pair such that each SOT-line of the twice patterned SOT-layer connects the first and second terminals of a respective terminal pair to each other. forming a layer stack comprising an MTJ layer structure and a spin-orbit torque layer, SOT-layer, below the MTJ layer structure; forming a first etch mask over the layer stack, the first etch mask comprising at least one first mask line extending in a first direction perpendicular to a stacking direction of the layer stack; patterning the layer stack to form at least one MTJ line extending in the first direction, the patterning comprising etching while the first etch mask masks the layer stack, and stopping etching on or above the SOT-layer; forming sidewall spacers on either side of each MTJ line; while the sidewall spacers mask the SOT-layer, etching the SOT-layer to form a patterned layer stack comprising the at least one MTJ line and a first patterned SOT-layer; forming a second etch mask over the patterned layer stack, the second etch mask comprising at least one second mask line extending across the at least one MTJ line in a second direction perpendicular to the stacking direction of the layer stack; and patterning the patterned layer stack comprising the first patterned SOT-layer and the at least one MTJ line to form a twice patterned SOT-layer, the twice patterned SOT-layer comprising at least one SOT-line extending in the second direction, and to form an MTJ pillar on each SOT-line, the patterning comprising etching while the second etch mask masks the patterned layer stack; wherein the layer stack is formed on an insulating layer embedding at least one terminal pair of a first and second terminal, the first and second terminals of each pair being spaced apart in the second direction and wherein the SOT-layer is formed in contact with the at least one terminal pair, and characterized in that the sidewall spacers on each respective MTJ line are formed to fully overlap the first and second terminals of a respective terminal pair such that each SOT-line of the twice patterned SOT-layer connects the first and second terminals of a respective terminal pair to each other.