Shantaram opens as Lin, a felon and heroin addict who has escaped from prison in Australia, arrives in Bombay. Trusting his instincts, Lin puts his faith in a guide, Prabaker, who leads Lin and some Canadian friends into the Colaba district of the city. Here Lin meets Karla and instantly falls for her. He becomes better friends with Prabaker, who offers to take Lin on a tour of "the real Bombay," and introduces him to a group of witty criminal expatriots (including Didier, Modena, Ulla, Maurizio, Vikram and Letitia) who frequent Leopold's, a local establishment.
Prabaker's tour of the real Bombay leads Lin into the dark underbelly of the city. He witnesses the slave market and visits the hashish den of the Standing Babas. Having grown very close to Lin, Prabaker invites him to visit his home village of Sundar. Lin agrees and they arrive after a cramped and adventurous journey by train and cart. At the village Lin relaxes into the seasonal rhythms. He finds a profound inner-peace and as a result the villagers dub him Shantaram, which means "man of peace."
The time comes to return to Bombay. While en route, Prabaker and Lin get drunk at an "unofficial" bar, and Lin is robbed. Without money and unable to get more because of his criminal past, Lin despairs; soon, however, Prabaker arranges for Lin to have a hut in his slum settlement. Here Lin meets Qasim, Johnny Cigar, and several more affable, wise poor slum dwellers. After a fire breaks out, Lin uses his modest medical training to help the injured. Before he knows it, he has become recognized as the slum doctor and his hut has become a clinic.
The head criminal in Bombay, Khader, approaches Lin through his underling, Abdullah. Khader appreciates Lin's work in the slum and offers to help with connections in the medical black market. Meanwhile, Khader takes Lin under his wing personally, inviting him to participate in philosophical discussions with his mafia council. Eventually, Khader calls upon Lin to teach his young nephew, Tariq, English. Lin resists at first but comes to appreciate the responsibility of raising the child.
Lin's love for Karla, in the meantime, remains strong. She visits him in the slum and asks of him a favor: a friend of hers, Lisa Carter, is stuck working as a prostitute for Madame Zhou, a notorious Bombay madam. Karla has a plan to rescue her in which Lin dresses up as an American consulate and asks for Lisa's release. Lin agrees to the plan and it goes off, though not very smoothly. He makes an enemy of Madame Zhou in the process. Lisa, having escaped from Madame Zhou's, crashes at Karla's place.
At the slum, cholera breaks out. Lin battles the epidemic night and day and Karla arrives to help. This experience brings them close and they make love at last. Just afterwards, however, Lin is arrested by the Bombay police and thrown into the deplorable Arthur Road Prison. After months of fighting off abuse by the overseer Big Rahul, Vikram finally arrives on Khader's behalf and releases Lin. He leaves jail only to learn that Karla has left town. However, Lin is able to track her down in the Indian state of Goa, and they share one last glorious night together before Lin returns to Bombay to work in Khader's mafia. Karla and he part for good - they think.
As a professional criminal, Lin learns the passport and currency black markets. He makes many journeys around India and beyond in Khader's employ. Things in Bombay grow more dangerous after Modena, Maurizio and Ulla are involved in a scheme to steal money from a Nigerian man. Maurizio blames Lin for the lost money, forcing Lin to defend himself against hit men. This feud comes to a boil and Lisa Carter ends up killing Maurizio in self-defense, but not before Maurizio has badly mutilated Modena. Lin calls upon a contact, Hassaan Obikwa, to dispose of Maurizio's body.
Two sequential tragedies take the novel to an even darker place. In the same chapter, Prabaker and Abdullah are both killed. Driven to despair by the loss of his two closest friends, Lin returns to heroin. He spends three months in Gupta-ji's opium den before Khader finds him and sends Karla to rescue him. Lin quits drugs cold turkey at Khader's beachside house in the company of Nazeer.
After he beats heroin, Khader asks Lin to accompany him to Afghanistan, where they will fight in the war against the Russian invaders. Lin agrees. They pass through Pakistan, where someone tries to turn them into the police. They are able to escape and journey into the mountains of Afghanistan, led by the murderously insane Habib. Lin settles into a guerilla camp, where he works as a medic. During their time in Afghanistan, Lin grows closer still to Khader, only to find that Khader has been spying on him in Bombay, including the establishment of his clinic and his relationship with Karla. Outraged, Lin refuses to accompany Khader on his journey back to Pakistan. Three days later, Nazeer returns to the camp dragging Khader's dead body.
Following Khader's death, the operation is in shambles. Eventually, the troops decide to make a break for Pakistan, trusting Habib's intelligence. Habib, though, has gone completely crazy. It turns out that he has killed some of his own allies, a revelation that causes his only friend, Khaled, to kill him and wander off into the wild alone. The remaining guerillas make a break for the border. They come under fire and Lin is knocked unconscious.
He comes to Pakistan, having been saved by Nazeer. Together, they return to Bombay in order to address several orders of business. First, they find and eliminate the traitor in their midst - who turns out to be Ghani, a trusted elder in their mafia circle who had been in charge of the "Sapna" project (an invented vigilante striking out at the rich on behalf of the poor). After a struggle, Ghani and his followers are killed and Salman becomes the head of the reorganized mafia. A second order of business involves Lin's time in prison - it turns out that he was arrested because of his feud with Madame Zhou. He goes off to seek revenge on the madam only to find that someone has beat him to it - her palace has been burned down and her power has evaporated. Rather than kill her, he leaves her in her misery.
Several surprises await Lin as the novel comes to close. For instance, he meets Modena, who has been badly mutilated and now works as a sort of sideshow entertainer. He also discovers that Abdullah was not killed after all; he survived the attempt on his life. With Abdullah back in action, the mafia takes on a final mission - to destroy Chuha's competing underworld organization. They are successful but Salman dies in the attempt, leaving the mafia to stray from the ways of Khader and embrace new, unscrupulous methods.
After this alteration in the nature of the mafia, Abdullah and Nazeer approach Lin and ask him to join them in another holy war, this time in Sri Lanka. Lin accepts. He then has a final revelatory talk with Karla, whom he is no longer in love with. Shantaram closes with a reunion between Lin and Prabaker's parents, whom he met at Sundar village. He visits Prabaker's widow, Pavarti, and notices that her son with Prabaker looks almost exactly like his father.