Foucault's thinking here is akin to the Daoist principle that all oppositions define each other. We cannot have a 'left' without a right; we cannot have a 'good' without an 'evil'; we cannot have 'authority' without 'dissidence'. Social power and social resistance are a chicken-and-egg phenomenon. Does the uncooperativeness of one group cause another group to grasp for social power, or does the grasp for social power of the second group cause the first to become uncooperative? All we really know is that so long as two people disagree, each will reach for power and each will resist the power of the other.
That being said, people attempt to resolve power/resistance disputes in many different ways. In the worst cases people resort to naked violence. This can be the direct violence of an oppressor against insurgents, the indirect violence of state or group terrorism, or even the 'soft' violence of coups, crime syndicates, etc, which seek to circumvent confrontation with established power instead of confronting it. More conventionally we have juridical systems where power is invested in an ostensibly neutral third party — tribal elders, religious leaders, magistrates or judges — who ostensibly decide between opposing parties on the grounds of fair and abstract principles. There is still the potential for violence in these cases, but that potential has been taken by the ruling body and is administered opaquely to keep it from spilling out into the community as a whole.
What Gandhi is saying — following Thoreau's concept of civil disobedience — is that solutions involving violence can only appear moral when there is alienation. To use violence against another one must see them as innately evil, criminal, dangerous, depraved, dysfunctional, radical, etc. They must first be reduced to threatening beasts and be metaphorically cast out of 'proper' human society, and then violence is undertaken either to force them into 'proper' society, to corral them into a secondary and subservient position, or to eliminate them outright. Non-violent solutions work on the opposite principle: to remove alienation; to force each side to see the other as fully human; to allow the power of the natural inclination of humans towards moral behavior to drive a wedge between the people who wield the tools of power and the structured use of those tools.
Thoreau was steeped in the genial and egalitarian world of early Massachusetts, and so his take on non-violence was genial and egalitarian. He argued one should merely refuse to comply with whatever violated one's moral sensibilities, neither offering resistance to nor hiding from authorities, and force the agents of the law into positions where they had to do violence to someone who seemed calm, moral, and reasonable. Thoreau reasoned that the sheer repugnance an agent would feel at inflicting violence on another 'human' would eventually break down the enforcement of any immoral law, rendering it moot. Gandhi's world was far less kind, so he focused on getting his followers to see and confront the British as humans and equals, reasoning this would eventually force the British to treat his followers in the same way.
In other words, instead of invoking the dualistic paradigm where power and resistance define each other, the idea was to remove the dualism: no more resistance means no more power: all that's left is humans facing each other as equals in community.
Rereading, this seems more Foucault-ish than a proper the Foucaultian analysis, but...