Harper Lee, whose first novel, “To Kill a Mockingbird,” about racial injustice in a small Alabama town, sold more than 40 million copies and became one of the most beloved and most taught works of fiction ever written by an American, died on Friday in Monroeville, Ala., where she lived. She was 89.

Hank Conner, a nephew of Ms. Lee’s, said that she died in her sleep at the Meadows, an assisted living facility.

The instant success of “To Kill a Mockingbird,” which was published in 1960 and won the Pulitzer Prize for fiction the next year, turned Ms. Lee into a literary celebrity, a role she found oppressive and never learned to accept.

“I never expected any sort of success with ‘Mockingbird,’ ” Ms. Lee told a radio interviewer in 1964. “I was hoping for a quick and merciful death at the hands of the reviewers, but, at the same time I sort of hoped someone would like it well enough to give me encouragement.”

The enormous success of the film version of the novel, released in 1962 with Gregory Peck in the starring role of Atticus Finch, a small­town Southern lawyer who defends a black man falsely accused of raping a white woman, only added to Ms. Lee’s fame and fanned expectations for her next novel.

But for more than half a century a second novel failed to turn up, and Ms. Lee gained a reputation as a literary Garbo, a recluse whose public appearances to accept an award or an honorary degree counted as important news simply because of their rarity. On such occasions she did not speak, other than to say a brief thank you.

Then, in February 2015, long after the reading public had given up on seeing anything more from Ms. Lee, her publisher, Harper, an imprint of HarperCollins, dropped a bombshell. It announced plans to publish a manuscript — long thought to be lost and now resurfacing in mysterious circumstances — that Ms. Lee had submitted to her editors in 1957 under the title “Go Set a Watchman.”

Ms. Lee’s lawyer, Tonja B. Carter, had chanced upon it, attached to an original typescript of “To Kill a Mockingbird,” while looking through Ms. Lee’s papers, the publishers explained. It told the story of Atticus and his daughter, Jean Louise Finch, known as Scout, 20 years later, when Scout is a young woman living in New York. It included several scenes in which Atticus expresses conservative views on race relations seemingly at odds with his liberal stance in the earlier novel.

The book was published in July with an initial printing of 2 million and, with enormous advance sales, immediately leapt to the top of the fiction bestseller lists, despite tepid reviews.

To Kill a Mockingbird” was really two books in one: a sweet, often humorous portrait of small­town life in the 1930s, and a sobering tale of race relations in the Deep South during the Jim Crow era.

Looking back on her childhood as a precocious tomboy, Scout, the narrator, evokes the sultry summers and simple pleasures of an ordinary small town in Alabama. At a time when Southern fiction inclined toward the Gothic, Ms. Lee, with a keen eye and a sharp ear for dialogue, presented “the more smiling aspects” of Southern life, to borrow a phrase from William Dean Howells.

At the same time, her stark morality tale of a righteous Southern lawyer who stands firm against racism and mob rule struck a chord with Americans, many of them becoming aware of the civil rights movement for the first time.

The novel had its critics. “It’s interesting that all the folks that are buying it don’t know they’re reading a child’s book,” Flannery O’Connor wrote in a letter to a friend shortly after the novel’s appearance. Some reviewers complained that the perceptions attributed to Scout were far too complex for a girl just starting grade school, and dismissed Atticus as a kind of Southern Judge Hardy, dispensing moral bromides.

The book soared miles above such criticisms. By the late 1970s “To Kill a Mockingbird” had sold nearly 10 million copies, and in 1988 the National Council of Teachers of English reported that it was being taught in 74 percent of the nation’s secondary schools. A decade later Library Journal declared it the best novel of the 20th century.

Nelle Harper Lee was born on April 28, 1926, in the poky little town of Monroeville, in southern Alabama, the youngest of four children. “Nelle” was a backward spelling of her maternal grandmother’s first name, and Ms. Lee dropped it when “To Kill a Mockingbird” was published, out of fear that readers would pronounce it Nellie, which she hated.

Her father, Amasa Coleman Lee, was a prominent lawyer and the model for Atticus Finch, who shared his stilted diction and lofty sense of civic duty. Her mother, Frances Finch Lee, also known as Miss Fanny, was overweight and emotionally fragile. Neighbors recalled her playing the piano for hours, fussing with her flower boxes and obsessively working crossword puzzles on the front porch. Truman Capote, a friend of Ms. Lee’s from childhood, later said that Nelle’s mother had tried to drown her in the bathtub on two occasions, an assertion that Ms. Lee indignantly denied.

Ms. Lee, like her alter ego Scout, was a tough little tomboy who enjoyed beating up the local boys, climbing trees and rolling in the dirt. “A dress on the young Nelle would have been as out of place as a silk hat on a hog,” recalled Marie Rudisill, Capote’s aunt, in her book “Truman Capote: The Story of His Bizarre and Exotic Boyhood by an Aunt Who Helped Raise Him.”

One boy on the receiving end of Nelle’s thrashings was Truman Persons (later Capote), who spent several summers next door to Nelle with relatives. The two became fast friends, acting out adventures from “The Rover Boys” and, after Nelle’s father gave the two children an old Underwood typewriter, making up their own stories to dictate to each other.

Mr. Capote later wrote Nelle into his first book, “Other Voices, Other Rooms,” where she appears as the tomboy Idabel Tompkins. She made a repeat appearance as Ann Finchburg, nicknamed Jumbo, in his story “The Thanksgiving Visitor.” Ms. Lee returned the favor, casting Mr. Capote in the role of the little blond tale­spinner Dill in “To Kill a Mockingbird.”

Ms. Lee attended Huntingdon College, a local Methodist school for women, where she contributed occasional articles to the campus newspaper and two fictional vignettes to the college’s literary magazine. Both gave an inkling of themes that would find their way into her novel. “Nightmare” described a lynching, and “A Wink at Justice” told the story of a shrewd judge who makes a Solomonic decision in the case of eight black men arrested for gambling.

After a year at Huntingdon, Ms. Lee transferred to the University of Alabama to study law, primarily to please her father, who hoped that she, like her sister Alice, might become a lawyer and enter the family firm. Her own interests, and perhaps her disposition, led her elsewhere.

“I think lawyers sort of have to conform, and she’d just as soon tell you to go to hell as say something nice and turn around and walk away,” a classmate recalled. Ms. Lee wrote a column called Caustic Comments for Crimson White, the campus newspaper, and contributed articles to the university’s humor magazine, Rammer Jammer, where she became editor in chief in 1946.

After her senior year, she spent a summer at Oxford University as part of a student­exchange program. On her return from England, she decided to go to New York and become a writer.

Ms. Lee arrived in Manhattan in 1949 and settled into a cold­water apartment in the East 80s. After working briefly at a bookstore, she found work as a reservations agent, first for Eastern Airlines and later for BOAC. At night she wrote on a desk made from a door. The local colony of displaced Southerners regarded her askance. “We didn’t think she was up to much,” recalled Louise Sims, the wife of the saxophonist Zoot Sims. “She said she was writing a book, and that was that.”

Michael and Joy Brown, a couple she met through Mr. Capote, believed in her. Mr. Brown, a lyricist, had just received a large check for his work on a musical fashion show for Esquire magazine, and on Christmas Day 1956 he and his wife presented Ms. Lee with a check equal to a year’s salary at BOAC and a note that read: “You have one year off from your job to write whatever you please. Merry Christmas.”

Slowly she developed a small portfolio of short stories, which she took to an agent, Maurice Crain. He suggested she try her hand at writing a novel. Two months later she returned with the first 50 pages of a manuscript she called “Go Set a Watchman.”

It told the story of a small­town lawyer who stands guard outside a jail to protect his client against an angry mob, a central incident in the novel­to­be, whose title Mr. Crain changed to “Atticus” and later, as the manuscript evolved, to “To Kill a Mockingbird.”

The title refers to an incident in the novel, in which Atticus, on giving air rifles to his two children, tells them they can shoot at tin cans but never at a mockingbird. Scout, puzzled, learns from Miss Maudie Atkinson, the widow across the street, that there is a proverb, “It’s a sin to kill a mockingbird,” and the reason for it: the birds harm no one and only make beautiful music.

Editors at Lippincott told Ms. Lee that her manuscript read like a string of anecdotes, not a novel, but encouraged her to revise. Eventually they paid a small advance and assigned her to work with Tay Hohoff, an experienced editor with whom she developed a close working and personal relationship.

As the novel made its way toward publication, Mr. Capote called with a proposal. He was going to Kansas to research the shocking murder of a farm family. Would she like to come along as his “assistant researchist”?

Ms. Lee jumped at the offer. “He said it would be a tremendously involved job and would take two people,” she later told Newsweek. “The crimes intrigued him, and I’m intrigued by crime — and, boy, I wanted to go. It was deep calling to deep.”

For months, Ms. Lee accompanied Mr. Capote as he interviewed police investigators and local folk. Engaging and down to earth, she opened doors that, without her, would have remained closed to her companion, whose flamboyantly effeminate manner struck many townspeople as outlandish. Each night she wrote detailed reports on her impressions and turned them over to Mr. Capote. Later she read his manuscript closely and offered comments.

When the book, “In Cold Blood,” was published in 1966 to much acclaim, Mr. Capote repaid her help with a brief thank you on the dedication page and thereafter minimized her role in the book’s creation. By then the friendship had already cooled and entered a deep freeze after “To Kill a Mockingbird” became a runaway best seller

Signs of its success were visible almost immediately after it was published in July 1960. Both Book­of­the­Month Club and the Literary Guild made the novel one of their selections, and Reader’s Digest condensed it. A week after publication, the novel jumped to the top of the best­seller lists? it remained there for 88 weeks.

Life magazine accompanied Ms. Lee around Monroeville, photographing her with her father on the front porch of the family home, posing on the balcony of the country courthouse and peering in the window of the ramshackle house that served as the model for the home of Boo Radley, the gentle, simple­minded neighbor who befriends Scout. One photograph bore the retrospectively poignant caption: “At her father’s law office where she wrote ‘Mockingbird,’ Miss Lee works on her next novel.”

The next novel refused to come. “Success has had a very bad effect on me,” Ms. Lee told The Associated Press. “I’ve gotten fat — but extremely uncomplacent. I’m running just as scared as before.”

In the months after the novel was published, she contributed two wispy articles to McCall’s and Vogue. To inquiring reporters, she threw out tantalizing hints of a second novel in progress, but the months and the years went by, and nothing appeared in print. She began turning down requests for interviews.

In one of her last interviews, with a Chicago radio show in 1964, Ms. Lee talked in some detail about her literary ambition: to describe, in a series of novels, the world she grew up in and now saw disappearing.

“This is small­town middle­class Southern life as opposed to the Gothic, as opposed to ‘Tobacco Road,’ as opposed to plantation life,” she told her interviewer, referring to the Erskine Caldwell novel, adding that she was fascinated by the “rich social pattern” in such places. “I would simply like to put down all I know about this because I believe that there is something universal in this little world, something decent to be said for it, and something to lament in its passing,” she continued. “In other words, all I want to be is the Jane Austen of South Alabama.”

The world waited impatiently, and grew accustomed to disappointment. At one point her sister told a British journalist that the nearly completed manuscript had been stolen from Ms. Lee’s apartment during a break­in. In the mid­1980s Ms. Lee became fascinated by a part­time preacher and serial killer whose story she intended to dramatize, after the manner of “In Cold Blood,” in a book tentatively titled “The Reverend.” She even set up camp for nearly a year in Alexander City, Ala., the site of the killings, to do research and absorb the atmosphere. But again nothing materialized.

In writing “Mockingbird: A Portrait of Harper Lee” (2006), Charles J. Shields maintained that he had conducted 600 interviews with friends, acquaintances and former classmates of his subject. Ms. Lee herself declined to cooperate, turning down his requests for an interview “with vigor,” he said.

Although reporters imagined a Southern Miss Havisham, Ms. Lee lived a quiet but relatively normal life in Monroeville, where friends and neighbors closed ranks around her to fend off unwelcome attention by tourists and reporters. She lived with Alice, who practiced law in her 90s and died in 2014 at 103.

Ms. Lee also attended the local Methodist Church (built in part from her royalties) and occasionally dropped in on English classes at the local high school when “To Kill a Mockingbird” came up for study. She also spent time in Manhattan, where she maintained a small apartment.

Occasionally there were sightings. In 2001, Ms. Lee began attending an annual awards ceremony at the University of Alabama to meet and talk with the winners of a contest for the best essay by an Alabama high school student on “To Kill a Mockingbird.”

In keeping with her longstanding policy, she refused to talk about her own life and work, which became a matter of intense journalistic curiosity again with the release of two films that dealt with the writing of “In Cold Blood.” In one, “Capote” (2005), Ms. Lee was portrayed by Catherine Keener and in the other, “Infamous” (2006), by Sandra Bullock. She did, however, send a letter to the magazine Oprah in 2006 describing her childhood love of reading.

In May 2013, her name appeared in news reports when she filed a lawsuit accusing her literary agent, Samuel Pinkus, of duping her into assigning the novel’s copyright to his company after a stroke she suffered in 2007 left her with impaired hearing and eyesight. When a friend suggested that she develop a form letter for refusing interviews, she appeared to give the matter some thought. What it would say, she told him, “is ‘Hell, no.’ ”

News of the rediscovery of “Go Set a Watchman” threw the literary world into turmoil. Many critics, as well as friends of Ms. Lee, found the timing and the rediscovery story suspicious, and openly questioned whether Ms. Lee, who was shielded from the press by Ms. Carter, was mentally competent to approve its publication.

It remained an open question, for many critics, whether “Go Set a Watchman” was anything more than the initial draft of “To Kill a Mockingbird,” from which, at the behest of her editors, Ms. Lee had excised the scenes from Scout’s childhood and developed them into a separate book. “I was a first­time writer, and I did what I was told,” Ms. Lee wrote in a statement issued by her publisher in 2015.

Many readers, who had grown up idolizing Atticus, were crushed by his portrayal, 20 years on, as a staunch defender of segregation.

“The depiction of Atticus in ‘Watchman’ makes for disturbing reading, and for ‘Mockingbird’ fans, it’s especially disorienting,” Michiko Kakutani wrote in a review of the book in The New York Times. “Scout is shocked to find, during her trip home, that her beloved father, who taught her everything she knows about fairness and compassion, has been affiliating with raving anti­integrationist, anti­black crazies, and the reader shares her horror and confusion.”

In her statement, Ms. Lee, who said that she had assumed the manuscript was lost, wrote, “After much thought and hesitation, I shared it with a handful of people I trust and was pleased to hear that they considered it worthy of publication.” This month, the producer Scott Rudin announced that he planned to bring “To Kill a Mockingbird” to Broadway in the 2017­18 season, with the screenwriter Aaron Sorkin adapting the novel and Bartlett Sher directing.

CREDIT: By William Grimes for New York Times