The screenplay of Gandhi is available as a published book. The film opens with a statement from the filmmakers explaining their approach to the problem of filming Gandhi's complex life story:
No man's life can be encompassed in one telling. There is no way to give each year its allotted weight, to include each event, each person who helped to shape a lifetime. What can be done is to be faithful in spirit to the record and to try to find one's way to the heart of the man...
The film begins on the day of Gandhi's assassination on 30 January 1948. After an evening prayer, an elderly Gandhi is helped out for his evening walk to meet a large number of greeters and admirers. One of these visitors, Nathuram Godse, shoots him point blank in the chest. Gandhi exclaims, "Oh, God!" ("H  Ram!" historically), and then falls dead. The film then cuts to a huge procession at his funeral, which is attended by dignitaries from around the world.
The early life of Gandhi is not depicted in the film. Instead, the story flashes back 55 years to a life-changing event: in 1893, the 23-year-old Gandhi is thrown off a South African train for being an Indian sitting in a first-class compartment despite having a first-class ticket. Realising the laws are biased against Indians, he then decides to start a nonviolent protest campaign for the rights of all Indians in South Africa. After numerous arrests and unwelcome international attention, the government finally relents by recognising some rights for Indians.
After this victory, Gandhi is invited back to India, where he is now considered something of a national hero. He is urged to take up the fight for India's independence, (Swaraj, Quit India) from the British Empire. Gandhi agrees, and mounts a nonviolent non-cooperation campaign of unprecedented scale, coordinating millions of Indians nationwide. There are some setbacks, such as violence against the protesters and Gandhi's occasional imprisonment. The Jallianwala Bagh massacre is also depicted in the film.
Nevertheless, the campaign generates great attention, and Britain faces intense public pressure. After World War II, Britain finally grants Indian independence. Indians celebrate this victory, but their troubles are far from over. The country is subsequently divided by religion. It is decided that the northwest area and the eastern part of India (current-day Bangladesh), both places where Muslims are in the majority, will become a new country called Pakistan. It is hoped that by encouraging the Muslims to live in a separate country, violence will abate. Gandhi is opposed to the idea, and is even willing to allow Muhammad Ali Jinnah to become the first prime minister of India, but the Partition of India is carried out nevertheless. Religious tensions between Hindus and Muslims erupt into nationwide violence. Horrified, Gandhi declares a hunger strike, saying he will not eat until the fighting stops. The fighting does stop eventually.
Gandhi spends his last days trying to bring about peace between both nations. He thereby angers many dissidents on both sides, one of whom (Godse) is involved in a conspiracy to assassinate him.
As Godse shoots Gandhi in a scene recalling the opening, the film cuts to black and Gandhi is heard in a voiceover, saying "Oh, God!" The audience then sees Gandhi's cremation; the film ending with a scene of Gandhi's ashes being scattered on the holy Ganga. As this happens, viewers hear Gandhi in another voiceover from earlier in the film:
 When I despair, I remember that all through history the way of truth and love has always won. There have been tyrants, and murderers, and for a time they can seem invincible, but in the end they always fall. Think of it. Always. 
As the list of actors is seen at the end, the hymns "Vaishnava Jana To" and "Raghupati Raghava Raja Ram" are heard.
Output: What was the division of India into Hindu and Muslim states called?