In 1896, when it had become clear that he would be spending a significant portion of his life in South Africa, Gandhi made a brief return to India in order to collect his wife and children. While there, he published a pamphlet on the plight of Indians in South Africa (known to history as the Green Pamphlet) and experienced the first taste of the popular adulation that his work would eventually win him. He had developed a reputation as a champion of the poorest laborers in Natal, and when he went to visit the Indian province of Madras, the region where most of the laborers had originated, cheering crowds and wild enthusiasm greeted him. But he had promised his South African friends that he would be gone only six months; accordingly, he packed up Kasturbai and his children and sailed from Bombay in December 1896.
Upon his return to South Africa, however, a riotous crowd of whites awaited him at Port Natal. Gandhi had developed a considerable reputation as a troublemaker, and they were determined that he should not be allowed to land. Considerable confusion also fueled their anger; many of the rioters mistakenly believed that a number of dark-skinned passengers were a large number of poor Indian immigrants that Gandhi had brought with him. However, Gandhi was saved and escorted to safety by the port's Police Superintendent and his wife–it would not be the first time that his ability to get along with Englishmen would serve him well. Meanwhile, the confusion over the "immigrants" was cleared up (they were mostly returning Indian residents of Natal), and Gandhi's standing in the local white community was actually improved as a result of the incident.
He was soon back to work at the Natal Indian Congress, but within three years the Boer War impeded his political progress. This conflict, fought between the British and the twin Boer Republics, had been a long time coming, and it ended–after three years of furious and often brutal fighting– with the absorption of the Transvaal and the Orange Free State into the Empire. During the war, Gandhi was able to find a way to merge his loyalty to Britain against the Boers with his ardent pacifism: he organized and led an Indian medical corps that served on the British side and conducted itself with great bravery at a number of battles, including Spion Kop in January of 1900.
The loyalty that led Gandhi to assist the British army in the Boer War, it should be noted, was no pro forma matter. Gandhi's views on the subject of empire would later alter dramatically, but at this point in his life, and indeed, until the 1920s, he was an ardent British patriot, and his pro-British stance resulted from much thought. The Empire, he felt, embodied the principles of equality and liberty that he believed in, and he regarded the racist policies of the South African states as an aberration, rather than a defining trait, of British rule. Indeed, he saw the Raj as benevolent rather than tyrannical; despite its flaws, he believed that the Empire had been good for India, and that the ideals of the British constitution merited the loyalty of all British subjects across the globe, white, black and Indian alike. The man who would later bring down white rule in India could still, at this point in his life, declare that he and his fellow Indians were "proud to be under the British Crown," believing that "England will prove India's deliverer."
The end of the Boer War, Gandhi hoped, would bring the establishment of true British justice throughout South Africa–and an opportunity for him to return, more or less permanently, to India. He left Natal for Bombay in 1901, but before he left, his friends in the Natal Indian Congress made him promise to return immediately if they needed him in their political efforts. It was a pledge that he would be soon called upon to fulfill.
One of Gandhi's principal motivations for his return to India was his desire to attend the 1901 meeting of the Indian National Congress. The Congress, upon which his own Natalese organization was modeled, had been founded in 1885 by an Englishman, in the hopes of creating a social and political forum for the westernized Indian upper class. It had no real political power, and tended to be pro-British–however, at this point, Gandhi was also pro-British, and he saw the Congress as the only national organization that could claim to speak for India. He attended the 1901 Congress in the hopes of seeing the passage of a resolution supporting the Indian population of South Africa, and his hope was realized, largely through the work of G.K. Gokhale, the most significant Indian politician of his day. Gokhale knew Gandhi from before his move to South Africa, and Gandhi stayed a month as a guest in his household, forging numerous connections that would serve him well later in life.