This whole concept of “independence” pretty much came in with the modern nation-state. Once the concept of The People forming their own Nation took hold, then you could speak of their becoming independent.
The way I look at it, to speak of France gaining independence from England in the Hundred Years’ War is not really relevant to the question. Because in those days a country was considered the fiefdom of its monarch. William the Conqueror ruled England and lived in England, but still held territory in France. Same for the Plantagenets. Was it a case of England “colonizing” France, or was it the French “colonizing” England? Neither. It was a case of an absolute monarch holding fiefdoms wherever he could gain them by conquest, inheritance, or marriage. The nature of the territory or ethnicity itself didn’t matter. Look, England hasn’t had a really English monarch since Aethelred or thereabouts. They got monarchs who were Danes, French, Normans, Welsh, Scots, Dutch … and for the past 300 years they’ve been Germans. The Prince of Edinburgh came from Greece, but who cares if he isn’t really “English”? That’s the way the game is played. The Tsarevich had hemophilia because it was passed to him by Queen Victoria. The crowned heads of Europe were all each other’s cousins, which shows that ethnicity and nationality had little to do with statecraft in their system. Ever since the Middle Ages, they’d been sending royalty around from one country to another.
So we can only begin to speak of a nation’s independence when the people themselves begin to gain independence from the monarchical system. Perhaps the first real independence movement in the modern sense was in the 16th century when the Dutch nation got independence from the Spanish king. And then a Dutch guy named Hugo de Groot first figured out the law of nations.
When Europeans colonized other continents, there was the sense of a people being dominated by another people, not just a monarch. Because of colonialism’s institutionalized inequality and racism. In this sense, Thailand was the most successful non-European country ever to resist colonialism. Thailand is my best candidate for the answer to the OP. I think they made out even better than Japan, because Japan was forced against her will to open up to foreign military might even though she wasn’t colonized. Iran remained technically independent even though de facto they came under British hegemony for some time.
Afghanistan had been part of the Mughal Empire in the 16th century; in fact, Afghanistan is where Babur first began to put together the Mughal Empire, before he went to India. His descendants weren’t able to hold onto it. In the 18th century, Afghanistan was part of the Afsharid Empire, conquered by Nadir Shah of Persia on his way to India. But again, this was the old model under which a monarch was a supranational entity. It wasn’t until the Afghans butted heads with British imperialism that the independence of the Afghan nation from the British nation became definite. British imperialism is what caused Afghanistan to coalesce into a nation-state, or rather an approximation of one. “Bobs” of Kandahar didn’t have to conquer it to earn that sobriquet, he just had to fight a battle there and acquit himself honorably. And then get his sorry butt the hell out of there before the Afghans sliced and diced it.