MUMBAI, India — It has been almost 70 years since Britain exited India.

That “Brexit” took two centuries of mutinies and protests, culminating in the nonviolent movement led by Gandhi, to compel the British to grant India independence in 1947 and leave soon after.

So Indians watched with interest as Britain, perceiving a threat to its sovereignty, voted in a referendum to leave the European Union. And they marveled at how much easier this Brexit was to achieve.

“If it was as easy as holding a referendum to separate, it would have happened for India much earlier,” said Shekhar Gupta, a former editor in chief of The Indian Express, an English-language newspaper in India.

But for the Indian Brexit to happen, Mr. Gupta said, “we had to drive them out.”

The Indian nationalist movement gained steam in the 1920s, when Gandhi began leading a nonviolent boycott of British products. The British imprisoned him and tens of thousands of others, trying in vain to stop the growing movement.

“If you had a referendum back then, India would have been 100 percent for Brexit out of India,” said Sanjaya Baru, a onetime spokesman for former Prime Minister Manmohan Singh.

“It is true the British detest the dour bureaucrats sitting in Brussels, ruling over the E.U., but that is nothing compared to the widespread anger back then against the white man in India,” Mr. Baru said.

But still the British hung on to India, relinquishing it only after being substantially weakened during World War II. And they did so reluctantly, noted the historian Ramachandra Guha, with some British generals convinced that India would be unable to govern itself and beg the British to return.

British colonialism in India began with the East India Company, which brought trade and its own private army. The legacy of the company can be seen in independent India’s reservations about foreign corporations, which have been welcomed only in recent years.

“We were colonized by a multinational company, so we were suspicious of foreign capital,” Mr. Guha said.

India’s exit from the British Empire may offer lessons for the European Union on what to expect next, he said. In the years after Indian independence, other British colonies in Asia and Africa made similar demands. One by one, from Sri Lanka to Malaysia, and Nigeria to Kenya, former colonies won independence.

“India Brexited, and these guys said, ‘Why not us?’” Mr. Guha said.

Mr. Baru said, “Brexit could trigger the collapse of the E.U. in the same way the Indian exit triggered the collapse of colonialism.”

But pushing the British out also made India vulnerable to ruptures from within. As the Indian nationalist movement began lobbying for freedom from the British, the All-India Muslim League began clamoring for a portion of the newly independent India to be partitioned as a separate Muslim-majority country, Pakistan.

“Brits, once you challenge the notion of being part of a larger whole, you leave yourself vulnerable to breaking yourselves up,” Mr. Gupta said. He wondered aloud how Britain would persuade Scotland to remain part of the United Kingdom when the Scots voted overwhelmingly to remain in the European Union.

India, with 29 states comprising different ethnicities and multiple languages, is as diverse as the European Union and more than twice as populous. Persuading people of the different regions to stay together was an enormous challenge accomplished by the first deputy prime minister of India, Vallabhbhai Patel.

Patel went to most of the self-governing princely states — then more than 500 in number — that had been released by the British and convinced almost all to join an independent India.

Both Britain and Europe need someone like Patel, Mr. Gupta said, “someone absolutely and totally committed and capable of convincing all of the remaining parts to stay together.”

(Source: New York Times)