Vargas Llosa has a zookeeper’s tenderness for the human “fauna” he describes in his fiction. Illustration by Patrick Bremer

In the course of Mario Vargas Llosa’s seventy-nine years, Peru has alternated between dictatorship and democracy with the sort of regularity that other countries experience through mere shiftings from one political party to another. During his nation’s most violent and despairing periods, Vargas Llosa must keenly have felt the truth of his own repeated assertion that the writer of fiction wishes to replace the world as it is with another one entirely.

His novels, the latest of which, “The Discreet Hero” (Farrar, Straus & Giroux), appears this month in the United States, have arisen from what Vargas Llosa calls Peru’s “effervescent structure of prejudices and sentiments,” the race-based obsession with social hierarchy which has helped produce the country’s calamitous political history. His books ignore none of Peru’s clashing, kaleidoscopic elements, but his vision, sometimes explicit and more often artistically indirect, is at bottom a gentlemanly, non-millenarian one, desirous of peace and pluralism, secularly hopeful of decency and democratic norms.

Vargas Llosa has filled his books with enough personal refractions to remind one of Alberto Moravia’s sense of the novel as “higher autobiography.” But if he has a genuine alter ego, an escapist projection of himself, it is the character of Don Rigoberto, introduced, in 1988, in a slender Ovidian tale called “In Praise of the Stepmother” and revived, a decade later, in “The Notebooks of Don Rigoberto” (1997). A Lima insurance executive by day, Rigoberto is by night a “libertarian hedonist,” enveloped in books and music and baroque sexual activity with his voluptuous second wife, Doña Lucrecia. He dictates her hairdressing and her jewelry, then orchestrates their erotic role-play with highbrow connoisseurship, directing Lucrecia to play figures painted by Titian and Boucher and Jordaens. Told in comically overdone prose (“We will take our pleasure in that half twilight that already is raping the night”), the couple’s adventures are enhanced by a comely housemaid named Justiniana and threatened by Don Rigoberto’s pre-adolescent and highly sexualized son, Fonchito, a cross between Tadzio and Lucifer whom his stepmother can’t resist.

In Don Rigoberto’s view, all things should lead to sex and “sovereignty,” a “horrendous glory” from which all civic responsibility disappears in favor of a fetish-fed “expression of human particularity.” In its mannered explicitness, “In Praise of the Stepmother” feels like something one prints privately and gives to a lover. For Vargas Llosa, it may have been a personal getaway, the release of an imaginative safety valve when he most needed it. As he readied the book for publication, a couple of years past his fiftieth birthday, he was preparing to run for the Presidency of Peru.

Vargas Llosa was born in 1936, in the southern city of Arequipa. He spent his early years being happily indulged by his mother’s family, the Llosas, after she was deserted by her struggling and sometimes violent husband, Ernesto Vargas. (Mario was allowed to believe that his father had died.) According to the author’s memoir, “A Fish in the Water” (1993), the Llosas “had been well-off and possessed of aristocratic airs” before a gentle descent into the middle class. His grandfather was related to José Luis Bustamante y Rivero, the Peruvian President who was ousted in a military coup by General Manuel Odría in 1948.

After a “secret reconciliation” with his wife, Ernesto Vargas reëntered his son’s life when Mario was eleven. “The nightmare of my childhood” began at that point, the author later recalled. Ernesto limited Mario’s contact with the Llosas (he resented their “airs” and their pampering of his son), and subjected him to verbal abuse and beatings. Eventually, Mario was sent to a military academy in Lima. The school provided the setting for Vargas Llosa’s first novel, “The Time of the Hero” (1962), the story of cadets who demonstrate all manner of gross, and even murderous, cruelty. For years, legend had it that, upon publication, a thousand copies had been burned on the academy grounds.

As a university student in the mid-nineteen-fifties, during the Odría dictatorship, Vargas Llosa made secret forays into political activity, joining a cell of Communists and contributing to an underground Marxist journal on “international subjects from the ‘proletarian’ and ‘dialectical’ point of view.” This mind-set helped make him a devotee of Gabriel García Márquez, about whom he published a lengthy book in 1971, and of Fidel Castro, but neither of these enthusiasms would survive the nineteen-seventies. The first ended with the Peruvian writer giving the Colombian a black eye. (The two of them made a pact never to speak of what provoked Vargas Llosa’s punch, though one popular theory suggests that García Márquez slept with his acolyte’s wife.) The attraction to Castro, whom Vargas Llosa had seen as a “romantic guerrilla leader,” turned into implacable moral opposition, a view of the dictator as “a little satrap with bloodstained hands.”

Vargas Llosa passed much of Latin America’s literary “Boom”—the years that made writers like García Márquez and Carlos Fuentes more than hemispherically famous—in Europe, teaching, translating, working in broadcast journalism, and publishing novel after novel. His literary predilections were, in great measure, European and North American, and, while he tried out some of the same narrative experiments as other Boom writers, his defection from the left made him a political outlier. Spain became his second, adopted homeland; years later, recalling its emergence from Francoism, he spoke of his discovery that “when good sense and reason prevail and political adversaries set aside sectarianism for the common good, events can occur as marvelous as the ones in the novels of magic realism.” He came to cherish incrementalism, and to view the history of his own country through a democratic, reformist lens. In an essay called “Fiction and Reality in Latin America,” he discerned even in the conquest of the Incas a message more anti-dictatorial than anti-imperialist: “The vertical and totalitarian structure of the Tahuantinsuyu was, without doubt, more of a threat to its survival than all the conquistadors’ firearms and iron weapons.”

During the nineteen-eighties, Peru began to crumble from corruption, drug violence, and terror attacks by the Maoist Shining Path movement. In “The Real Life of Alejandro Mayta” (1984), a novel set a few years into the future, the narrator declares, “Since it is impossible to know what’s really happening, we Peruvians lie, invent, dream, and take refuge in illusion. . . . Peruvian life, a life in which so few actually do read, has become literary.” And yet it was at this moment that Vargas Llosa slowed his prodigious literary output and allowed himself to catch the “disease” of practical politics. “A Fish in the Water” chronicles his role in forming the Democratic Front, the party that ran him for President in 1990. Vargas Llosa saw the threat of totalitarianism in the rigid state-driven economy and the nationalizations imposed by the ruling American Popular Revolutionary Alliance. He instead proposed a “radical liberalism,” an array of free-market reforms, and a revitalization of civil liberties.

The campaign was chaotic and thrilling. The novelist fended off lies about his finances, threats to his life, and attacks on the supposed depravity of his books: “In Praise of the Stepmother” was read, one chapter per day, during prime time on government-run television. Slender and elegant, the author-candidate looked more patrician than he actually was, and couldn’t overcome a cool, Kennedyesque refusal to be carried on his supporters’ shoulders, “a ridiculous custom of Peruvian politicians in imitation of bullfighters.” Vargas Llosa was asking to lead a nation that he was beginning to recognize as “not one country, but several, living together in mutual mistrust and ignorance, in resentment and prejudice, and in a maelstrom of violence.”