While promoting the civil rights of Indian residents of South Africa, Gandhi urged his fellow "coolies" to peacefully disobey British laws giving them a second-class status. He endured personal attacks without aggression. He believed peaceful resistance to injustice without retaliation or even self-defense would eventually win British respect. This was successful. However, when British South Africans fought Dutch South Africans in the Boer War, Gandhi maintained that Indians fighting with their British masters to defend their neighbors would also win respect and accomplish good. Not the Deepak Chopra mindset.
Back in India, Gandhi continued to advocate nonviolent resistance to injustice as the best way to win both a civil rights struggle and British respect. This method worked because of two factors. Gandhi offered an inspiring yet humbling moral example and the British leaders gave a grudging respect to the neighbor-loving principles of Jesus, which Gandhi wielded like a club to beat them over their heads. He was a moral jedi. Had British nobility found the Bible as easy to publically mock as brown people, Gandhi's way would have failed. (It later did!)
It is worth noting that Gandhi's moral philosophy was based in great part on the Bhagavadgita and the Bible. Think about that. The Gita focuses on the moral dilemma of Arjuna when called to fight a battle against his own family. God's avatar Krishna instructs him to obey his moral duties (whether hugging one's enemy or killing one's friend) rather than his emotional sentiments.
When the Japanese invaded nearby Burma in World War II, Gandhi took a nonpacifist stance. He suggested India fight alongside Britain in the event of a Japanese invasion in return for their recognition of Indian independence. Not a deal my hippie friends would broker.
Gandhi screwed up. (We all do.) Mahatma's love and peace schtick was less successful with hypocritical Indian Muslims and Hindus than it had been with hypocritical British Christians. Most of my Muslim friends in India today are glad their grandparents resisted the migration to separatist Muslim states and feel Gandhi should have been less passive about that division too.
Gandhi was at his best when he stood for neither violence nor nonviolence but for human rights and God's righteousness. Good people dislike a world of violence but have no greater love for a world where bullies who relish fullfilling their desires by rape and murder enslave the rest of us while no one resists. The Bible and the Bhagavadgita still offer more spiritual wisdom than the Internet. If you wanna be more like Gandhi, read 'em and heed 'em.