In 1944, Margelov became the commander of the 49th Guards Rifle Division. During the Bereznegovatoye–Snigirevka Offensive, the division crossed the Dnieper on the night of 12 March. On the next night, the rapidly advancing division crossed the Inhulets River and captured Kherson within a few hours. The division was awarded the title "Kherson" and Margelov became a Hero of the Soviet Union on 19 March. Margelov led the division through the Second Jassy–Kishinev Offensive, Belgrade Offensive, Budapest Offensive, Vienna Offensive and the Prague Offensive. During fighting outside Budapest, the division repulsed German counterattacks on the night of 13–14 February 1945. For its actions the division was awarded the Order of Suvorov 2nd class. In the Moscow Victory Parade of 1945, he commanded a battalion on the regiment representing the 2nd Ukrainian Front.