With the outbreak of the Second World War, JP and other socialist leaders believed that the pressure of freedom struggle might release forces that move and metamorphose the leadership. Hence, a mass struggle always threw up new leaders. In December, 1939 as general secretary of the CSP, JP called upon the people to take advantage of the war to stop British exploitation of India and to overthrow the British Government, to stop payment of rent and revenue; to establish their own government to organize a general strike and to stop the Tata Iron & Steel Company from supplying steel for the prosecution of the war. JP was arrested and imprisoned for nine months. After his release, JP met both Gandhi and S. C. Bose to bring about a rapprochement between the two. His efforts did not bear fruit. He was soon arrested and kept in Arthur Road Prison in Bombay and then sent to the Delhi Camp Jail. In his unsuccessful effort to smuggle out a packet of letters, the British Government falsely implicated him by charging that he had been plotting to bring about an armed insurrection in India.
However Gandhi's attitude towards JP was not one of anger. Gandhi held the British rule responsible for encouraging violent & revolutionary feeling in the country.
In August, 1942, Quit India war was launched by Gandhi. JP was still in Hazaribagh Central Jail. He was too restless to remain inside and escaped from the prison with five comrades by scaling down the prison walls. Throughout, the colonial period JP often advocated the use of arms in the struggle for freedom, contrary to the stand of Gandhi. Then JP left for Nepal and organized and trained an “Azad Dasta“ (Freedom Brigade) there to paralyze the machinery of the British Government. Finally, he was again arrested in a running train in Punjab in September, 1943 and in December; he was declared a state prisoner. He was kept in Lahore fort. He was subjected to in human tortures to get necessary information. In January, 1945, after 16 months, he was transferred to Agra Jail due to the great anger of the Indian people. Gandhi in the meantime made it clear to the Cabinet Mission that unless both JP and Dr. Lohia were unconditionally released. The negotiations would not start. Due to this both JP and Dr. Lohia were released in April 1946. The two men were given a heroic welcome by the people. JP was recognized as ”The Heart of India”, “The King of the Hearts of the youth.” The CSP played a glorious and important role in the struggle that followed the “Quit India” movement.
The politics at that time was marked by strife and petty jealousies among congressmen. Gandhi was again determined to launch a mass movement for the independence of India even without the support of the Congress leaders. JP at this juncture was certainly inclined towards Gandhi. JP also believed that the congress had taken a wrong line in adopting the constitutional method and ultimately agreeing to the Partition of the country. Hence, the partition came as a rude shock to the socialists, including JP.