The novel Swami and Friends is an episodic narrative that follows the daily life of Swaminatharian, a charismatic and lazy schoolboy, in the fictional South Indian town of Malgudi with his father, mother, and granny. He attends the Albert Mission School and has an established cadre of friends, including Samuel "the Pea," Sankar, Somu, and Mani, but the arrival of a new boy in school, Rajam, son of the police superintendent who speaks English like a European, threatens Swami’s popular status. They become rivals, enemies even, but swiftly reconcile and become fast friends. Swami invites Rajam over to his house and gives orders for his family to change their behavior and clean up to put a good face for Rajam, whose family comes from more money. Swami’s old friends—the Pea, Sankar, and Somu—feel abandoned by his budding friendship with Rajam and begin calling Swami “Rajam’s tail” to humiliate him. Rajam eventually brings everyone together to his house and urges them to reconcile and get along, bribing them with prizes, which ends up working.
Swami and Rajam, along with Mani, a tall strong boy who can beat up almost anyone, become a loyal trio. Swami gets into some trouble with another boy, the coachman’s son, after trying to get enough money to buy a wheel. Interrupting their provincial play is a nationalist strike as part of Gandhi's non-cooperation movement. Swami is swept up in the frenzy of the crowd and throws stones at the window of the headmaster's room, breaking it. The crowd of protestors is broken up by the policemen who violently beat the protestors, led by Rajam’s father, the superintendent.
The next day, the headmaster questions and punishes him and all the students who were missing from school. Swami, acutely distressed, runs away from the school, muttering, “I don’t care for your dirty school.” He is kicked out of the missionary school and enrolls in the Board High School, deemed a more inferior institution. Rajam forgives Swami for his “political sins” and posits that they start a cricket club, which he crowns the Malgudi Cricket Club or M.C.C. for short. They gather their friends together and practice, but Swami arrives late to every practice because he is kept at school until late in the afternoon. Rajam grows exasperated by Swami’s tardiness and, with a friendly match coming up, coerces Swami to plead with the headmaster to let Swami leave class early for his cricket practice. The headmaster declines. Swami becomes desperate and asks a doctor to give him a certificate allowing him to leave early. The doctor refuses, but says that he will speak to the headmaster. Swami begins leaving class early for cricket class, until the headmaster comes in and calls his truancy out in front of the classroom. The headmaster begins beating Swami, who is overcome with a mix of rage and humiliation. He takes the cane out of the headmaster’s hands, throws it out the window, and runs away.
After the incident, Swami believes that he is doomed, kicked out of the two high schools, unable to face his father’s wrath at home. He sees his only option is to escape the town entirely, only coming back anonymously to play the cricket game. He wanders off but gets lost and very hungry and begins to miss his home. He regrets his decision to escape. He begins having wild, scary dreams and falls asleep on the road, where he is picked up by a man carrying a cart. Meanwhile, his father has been roaming the town looking for him and his mother and granny are very anxious. When the man identifies Swami, he calls his parents and they pick him up. Swami is relieved to be found but upset when Mani tells him that he missed the cricket match and that M.C.C. lost. Rajam declares that he no longer cares for Swami and they stop being friends. One night, Mani divulges to Swami that Rajam and his family are leaving Malgudi permanently because his father got transferred to another city. Swami wakes up early the next day to say goodbye to Rajam at the train station and give him a gift, a volume of Hans Christen Anderson’s Fairy Tales. They manage to wriggle their way through the crowd of police officers who are sending Rajam's family off, and Swami and Rajam face each other. Swami cries out that Rajam is going away and when will he ever come back? Rajam opens his mouth to respond, but his response is lost in the locomotion of the trains as it chugs away. Mani runs alongside the train and gives Rajam the gift of books. The train leaves, and Swami cries, wondering if Rajam will ever think about him again, and Mani tries to console him by saying that Rajam will write letters to Swami, but his answer seems flimsy and his face inscrutable.