In June 1940, Panin was appointed head of combat training for the Leningrad Military District. He was promoted to Major General on 4 June. In March 1941, he became commander of the 42nd Rifle Corps. After the German invasion of the Soviet Union on 22 June, the corps became part of the 14th Army. It fought in the defense of Murmansk during Operation Silver Fox. On 24 August 1941, Panin became commander of the 14th Army, leading it in the defense of Murmansk. He was considered incompetent by Murmansk CPSU Regional Committee First Secretary and 14th Army Military Council member Maxim Starostin and later appointed commander of the 2nd Reserve Army in May 1942. In August 1942 Panin became a senior lecturer at the Frunze Military Academy. In February 1943, he was appointed chief of combat training for the Volkhov Front. Panin became commander of the 7th Rifle Corps of the 59th Army in September, leading it in the Leningrad–Novgorod Offensive and the capture of Novgorod. For his leadership in the offensive Panin was awarded the Order of Kutuzov 2nd class on 21 February 1944. Between April and May 1944 he was commander of the 99th Rifle Corps of the 3rd Baltic Front. In May, Panin was at the disposal of the chief of staff. In June he visited the 3rd Belorussian Front with Aleksandr Vasilevsky. One month later he became deputy commander of the 5th Army, participating in Operation Bagration and the East Prussian Offensive. In February 1945, he was hospitalized and from May 1945 was again at the disposal of the chief of staff.