Mohandas Karamchand Gandhi was born on 2 October 1869 into a Gujarati Hindu Modh Baniya family in Porbandar (also known as Sudamapuri), a coastal town on the Kathiawar Peninsula and then part of the small princely state of Porbandar in the Kathiawar Agency of the Indian Empire.

In May 1883, 14-year-old Kasturba was married to 13-year-old Mohandas Karamchand Gandhi in a marriage arranged by their parents, in the traditional Indian manner.

On 10 August 1888, Gandhi aged 18, left Porbandar for Mumbai, then known as Bombay. Upon arrival, he stayed with the local Modh Bania community while waiting for the ship travel arrangements. The head of the community knew Gandhi's father. After learning Gandhi's plans, he and other elders warned Gandhi that England would tempt him to compromise his religion, and eat and drink in Western ways. Gandhi informed them of his promise to his mother and her blessings. The local chief disregarded it, and excommunicated him from his caste. But Gandhi ignored this.

On 4 September, he sailed from Bombay to London. His brother saw him off.Gandhi attended University College, London which is a constituent college of University of London.

Gandhi, at age 22, was called to the bar in June 1891 and then left London for India, where he learned that his mother had died while he was in London and that his family had kept the news from him.

In 1893, a Muslim merchant in Kathiawar named Dada Abdullah contacted Gandhi. Abdullah owned a large successful shipping business in South Africa. His distant cousin in Johannesburg needed a lawyer, and they preferred someone with Kathiawari heritage. Gandhi inquired about his pay for the work. They offered a total salary of £105 plus travel expenses. He accepted it, knowing that it would be at least one-year commitment in the Colony of Natal, South Africa, also a part of the British Empire. In April 1893, Gandhi aged 23, set sail for South Africa to be the lawyer for Abdullah's cousin.

The Abdullah case that had brought him to South Africa concluded in May 1894, and the Indian community organized a farewell party for Gandhi as he prepared to return to India. However, a new Natal government discriminatory proposal led to Gandhi extending his original period of stay in South Africa. He planned to assist Indians in opposing a bill to deny them the right to vote, a right then proposed to be an exclusive European right.

Along with many other texts, Gandhi studied Bhagavad Gita while in South Africa. This Hindu scripture discusses jnana yoga, bhakti yoga, and karma yoga along with virtues such as non-violence, patience, integrity, lack of hypocrisy, self-restraint and abstinence. Gandhi began experiments with these, and in 1906 at age 37, although married and a father, he vowed to abstain from sexual relations.

In 1906, the Transvaal government promulgated a new Act compelling registration of the colony's Indian and Chinese populations. At a mass protest meeting held in Johannesburg on 11 September that year, Gandhi urged Indians to defy the new law and to suffer the punishments for doing so.

Gandhi expanded his nonviolent non-co-operation platform to include the swadeshi policy – the boycott of foreign-made goods, especially British goods. The appeal of "Non-cooperation" grew, its social popularity drew participation from all strata of Indian society. Gandhi was arrested on 10 March 1922, tried for sedition, and sentenced to six years' imprisonment.

Gandhi began his sentence on 18 March 1922. With Gandhi isolated in prison, the Indian National Congress split into two factions, , opposing this move. Furthermore, co-operation among Hindus and Muslims ended as Khilafat movement collapsed with the rise of Ataturk in Turkey. Muslim leaders left the Congress and began forming Muslim organizations. The political base behind Gandhi had broken into factions.

Gandhi was released in February 1924 for an appendicitis operation, having served only two years.

On 31 December 1929, the flag of India was unfurled in Lahore.

Gandhi joined the Indian National Congress and was introduced to Indian issues, politics and the Indian people primarily by Gokhale (the key leader of the Congress Party). Gandhi took leadership of the Congress in 1920 and began escalating demands until on 26 January 1930 the Indian National Congress declared the independence of India. The British did not recognize the declaration but negotiations ensued, with the Congress taking a role in provincial government in the late 1930s.

Gandhi led Congress celebrated 26 January 1930 as India's Independence Day in Lahore. This day was commemorated by almost every other Indian organisation. Gandhi then launched a new Satyagraha against the tax on salt in March 1930.

Gandhi sent an ultimatum in the form of a polite letter to the viceroy of India, Lord Irwin, on 2 March. A young left wing British Quaker by the name of Reg Reynolds delivered the letter. Gandhi condemned British rule in the letter, describing it as "a curse" that "has impoverished the dumb millions by a system of progressive exploitation and by a ruinously expensive military and civil administration... It has reduced us politically to serfdom." Gandhi also mentioned in the letter that the viceroy received a salary "over five thousand times India's average income. British violence, Gandhi promised, was going to be defeated by Indian non-violence.

This (Gandhi's letter to the viceroy of India) was highlighted by the famous Salt March to Dandi from 12 March to 6 April, where, together with 78 volunteers, he marched 388 kilometres (241 mi) from Ahmedabad to Dandi, Gujarat to make salt himself, with the declared intention of breaking the salt laws. Thousands of Indians joined him on this march to the sea. The march took 25 days to cover 240 miles with Gandhi speaking to often huge crowds along the way.

The government, represented by Lord Irwin, decided to negotiate with Gandhi. The Gandhi–Irwin Pact was signed in March 1931. The British Government agreed to free all political prisoners, in return for the suspension of the civil disobedience movement. According to the pact, Gandhi was invited to attend the Round Table Conference in London for discussions and as the sole representative of the Indian National Congress. The conference was a disappointment to Gandhi and the nationalists. Gandhi expected to discuss India's independence, while the British side focused on the Indian princes and Indian minorities rather than on a transfer of power.

In 1932, Gandhi began a new campaign to improve the lives of the untouchables, whom he started referring to as Harijans or "the children of god". On 8 May 1933, Gandhi began a 21-day fast of self-purification and launched a one-year campaign to help the Harijan movement. This new campaign was not universally embraced within the Dalit community. Ambedkar and his allies felt Gandhi was being paternalistic and was undermining Dalit political rights.

Gandhi opposition to the Indian participation in World War II was motivated by his belief that India could not be a party to a war ostensibly being fought for democratic freedom while that freedom was denied to India itself. He also condemned Nazism and Fascism, a view which won the endorsement of other Indian leaders. As the war progressed, Gandhi intensified his demand for independence, calling for the British to Quit India in a 1942 speech in Mumbai. This was Gandhi's and the Congress Party's most definitive revolt aimed at securing the British exit from India. The British government responded quickly to the Quit India speech, and within hours after Gandhi's speech arrested Gandhi and all the members of the Congress Working Committee. His countrymen retaliated the arrests by damaging or burning down hundreds of government-owned railway stations, police stations, and cutting down telegraph wires.

At 7:35 pm on 22 February 1944, Kasturbai Mohandas Gandhi died at the Aga Khan Palace in Poona, aged 74.

Gandhi was released before the end of the war on 6 May 1944 because of his failing health and necessary surgery; the Raj did not want him to die in prison and enrage the nation. He came out of detention to an altered political scene – the Muslim League for example, which a few years earlier had appeared marginal, "now occupied the centre of the political stage".

Gandhi tried to test and prove to himself his brahmacharya. The experiments began some time after the death of his wife in February 1944. At the start of his experiment, he had women sleep in the same room but in different beds. He later slept with women in the same bed but clothed, and finally, he slept naked with women. In April 1945, Gandhi referenced being naked with several "women or girls" in a letter to Birla as part of the experiments.

In August 1947 the British partitioned the land with India and Pakistan each achieving independence on terms that Gandhi disapproved.

At 5:17 pm on 30 January 1948, Gandhi was with his grandnieces in the garden of the former Birla House (now Gandhi Smriti), on his way to address a prayer meeting, when Nathuram Godse fired three bullets from a Beretta M1934 9mm Corto pistol into his chest at point-blank range. According to some accounts, Gandhi died instantly. In other accounts, such as one prepared by an eyewitness journalist, Gandhi was carried into the Birla House, into a bedroom. There he died about 30 minutes later as one of Gandhi's family members read verses from Hindu scriptures.