I had heard that it was a major factor in the heated history between the two countries.
Libraries worth of books have been written on this topic but I will try and give a condensed version here.
British saw Indian independence coming since early 40s. Roosevelt pushed for the Atlantic charter to be applied to the commonwealth, but Churchill went back on that. The world war had severely weakened the British empire, and India was looted for such a long time that it wasn't as profitable anymore.
The emergence of the oil trade in the middle east and the reliance of EU/NA made it so that the British believed it to be critical to repel USSR influence in that region.
At this time, Afghanistan was also under British influence. A very narrow strip of 22 km separated undivided India from USSR. The ever-close Indian independence left the British fearing that a free India may turn communist or be heavily influenced by USSR, allowing it more power in south Asia, and in turn, the Indian ocean, thus compromising the newly emerged oil from another front.
During this time, a small portion of the Muslim leaders in undivided India, the Muslim League, under the leadership of Muhammad Ali Jinnah (who later became the governor- general of newly- formed Pakistan) were asking for creation of a separate Islamic nation. Note that a very small minority voiced this thought. Indeed, in the elections of 1939, they only secured 1/4th of the reserved Muslim seats.
The British, seeing this as an opportunity, sought to exploit the Muslim league, especially Jinnah, in order to create a separate nation called Pakistan, which could serve as a buffer between partitioned India and USSR since Pakistan would be heavily influenced by the British, since it was primarily through their efforts that this new nation was created.
Then, without holding any referendums or polls, the British announced partition of undivided India into Pakistan and India (the modern India) on June 3, 1947. Once again, note that majority of the Muslim population did not want this (highlighted further by the fact that majority of the ‘Indian muslins’ chose to stay in India rather than migrate to newly- formed Pakistan). The independence date was announced to be in June 1948.
Jinnah was dying of tuberculosis. If he were to die before India could be divided, this grand scheme would have fallen apart. So viceroy Mountbatten changed the partition deadline to August 15th, 1947. Only 73 days. It is literally impossible to allow time for millions of people to move, divide government resources, officials, documents, military, soldiers, create new borders, in 73 days. Once again, to reiterate, the only reason India was being divided was to counter USSR’s influence in South Asia, and the only reason it was being done in a hurry was because Jinnah was dying (he died within a year of the partition).
Result was chaos, obviously. Wide- spread chaos that, accompanied with feelings of betrayal and newly- formed charged atmosphere led to riots in many places, leaving millions dead.
The military on both side was still composed of the British officers at higher ranks. Pakistani British officers continued to play a role in development of an attack on India (when they were supposed to remain neutral). With the the top ranks of Pakistani army occupied by the british, plans for an Indo- Pak war were drawn. (EDIT) The newly- formed Pakistan government was involved heavily in this too; war plans were reported back to UK (supposed to be a neutral party at this point) by the high- ranking officers involved, but in turn, India was not notified like it was supposed to.
So then, to sum it up, a hurried withdrawal from India and the partition, was a result of a carefully calculated strategy to counter the spreading USSR influence in South Asia and the growing oil interest in the Middle- East. It was not what the people of undivided India wanted. It left millions dead. The carefully orchestrated war soon after made peaceful co-existence nearly an impossibility for the years to come.
PM me if you wanna talk more man. Cheers.