The Mg-series was built for the electrification of Norra Stambanan in the 1940s. It was steeper and more curved than the main lines in Southern Sweden, and single-track sections meant that long freight trains had to be used to make best use of line capacity. The D-series was not powerful enough and the Of-series was too long for the curves. But as experience of the building of bogie-locomotives increased, a Co'Co'-design was chosen for Mg, as the first bogie-locomotive in Sweden. More power also meant that the direct current motors from the D-series had to be replaced with the alternating current motors of the F-series. The machine room was not symmetric, so the loco was not the same on the right and left side. The Mg was the basis for the Ma-series built in the 1950s.