British writer Gillian Freeman, who ventured outside the mainstream to write a landmark work of gay literature that is credited with helping to liberalize British attitudes toward homosexuality, died Feb. 23 at a hospital in London. She was 89.

The cause was complications from dementia, said her husband, Edward Thorpe.

Freeman’s boundary-breaking work

Ms. Freeman’s first book, “The Liberty Man” (1955), which she began writing when working as a secretary for novelist Louis Golding, was about a middle-class schoolteacher and a cockney sailor whose love affair is stifled by the British class system.

She went on to write scripts for television, radio and an early Robert Altman film; scenarios for Royal Ballet choreographer Kenneth MacMillan; and about a dozen more novels, often featuring undercurrents of romance and mystery, with protagonists who are outcasts by virtue of their religion, class or sexuality.

Raised in a liberal, middle-class London family, Ms. Freeman was no outsider. But she had a strong sympathy for those who were and an imagination that enabled her to craft fully realized characters such as Dick and Reggie, the gay, motorcycle-riding protagonists of “The Leather Boys” (1961).

The novel was commissioned by her literary agent turned publisher, Anthony Blond, who was bisexual. “Anthony said to her, ‘I would like a Romeo and Romeo story about simple young men, working-class young men,’ ” Thorpe said in a phone interview. “It was rather like the two guys in ‘Brokeback Mountain,’ which she preceded by about 40 years.”

Marketed as a British take on the Marlon Brando film “The Wild One,” Ms. Freeman’s novel featured shoplifting and theft, a preponderance of black leather jackets, a failed marriage and a male friendship that develops into a sexual relationship.

“When you kiss me . . . you don’t pretend I’m a girl or anything?” Dick asks his new lover. “Don’t be daft,” Reggie says. “ ’ow could I pretend you was a girl? You’re the wrong shape . . . I don’t want to pretend you’re a girl, neither.”

“The Leather Boys” was published six years before homosexuality was decriminalized in England and was part of a wave of boundary-breaking gay novels that included works by Christopher Isherwood, Mary Renault and (posthumously) E.M. Forster.

It “played a vital part in liberalizing British attitudes to homosexuality,” novelist Michael Arditti wrote in the foreword to the 2014 reissue of “The Leather Boys.”

Ms. Freeman released the book under a pseudonym, Eliot George, inverting the nom de plum that Mary Ann Evans used to publish “Middlemarch.” She used her own name while serving as screenwriter for a 1964 film adaptation drawn from “the novel by Eliot George.”

Directed by Sidney J. Furie, the movie featured actress Rita Tushingham and tweaked the novel’s plot, keeping Reggie’s unhappy marriage but having him spurn the advances of a gay biker, now named Pete. “The playing is exceptionally real, lines overlapping, almost improvised,” wrote Washington Post film critic Richard L. Coe. “Understatement has made this story meaningful; overstatement would have made it merely sensational.”

Ms. Freeman went on to survey the state of modern pornography in “The Undergrowth of Literature” (1967), which drew from magazines like Woman’s Own and Man’s Story to examine “the particular fantasies people need to get through life,” her husband said.

And she wrote two major novels set in Nazi Germany, including “The Alabaster Egg” (1970), about a Jewish woman’s tragic romance, and “Nazi Lady: The Diaries of Elisabeth von Stahlenberg, 1933-1948” (1978), which originally omitted Ms. Freeman’s name from the cover.

Appearing to be an authentic Nazi diary, the novel chronicled the daily life of a woman who marries an employee of propaganda minister Joseph Goebbels, meets Adolf Hitler and espouses the necessity of accepting “a certain amount of violence to achieve peaceful ends.” Ms. Freeman’s identity as author was soon revealed by the Evening Standard, but by then, the book had already fooled plenty of readers.

According to the Telegraph, Blond wrote in a memoir that historian and conservative politician Alan Clark declared the novel “indisputably genuine . . . a contemporary document of the highest importance to social historians of the epoch.” American publishers, meanwhile, offered to double their advance if “von Stahlenberg” would agree to a book tour.

Early life

Gillian Freeman was born in London on Dec. 5, 1929. Her mother was a homemaker, and her father was a physician turned dentist, who encouraged 5-year-old Gillian’s writing efforts by clipping together her handwritten stories about dogs and fairies.

She received a bachelor’s degree in English and philosophy, with honors, from the University of Reading in 1951. After moving to London, she worked as a copywriter, East End schoolteacher and newspaper reporter before being hired by Golding, one of her father’s dental patients.

Ms. Freeman married Thorpe, a ballet critic and novelist, in 1955. They later co-wrote “Ballet Genius” (1988), which featured profiles of 20 leading dancers. By then, Ms. Freeman had written scenarios for MacMillan’s ballets “Isadora” and “Mayerling,” which depicted a suicide pact between Crown Prince Rudolf of Austria and his mistress.

In addition to her husband, survivors include two daughters, actresses Harriet Thorpe and Matilda Thorpe; and five grandchildren.

Ms. Freeman’s other works included the screenplay for Altman’s “That Cold Day in the Park” (1969), based on a thriller by Richard Miles, and her novel “An Easter Egg Hunt” (1981), about a 17-year-old girl’s disappearance at a boarding school during World War I.

Her “Nazi Lady” continued to bedevil inattentive readers in recent years. When Canongate published “The Secret Annexe” (2004), an anthology of war diarists edited by Irene and Alan Taylor, the book included an excerpt from the diary of Elisabeth von Stahlenberg.

What Toni Morrison meant to 8 black women writers (including Michelle Obama)

‘She showed how incomplete the world’s narrative was without ours in it’

What Toni Morrison taught me about being a mother

Her mothering life has long been as important to me as her literary legacy

In Toni Morrison’s words, I found the wisdom and protection my mother wasn’t able to provide

Writer Nadia Owusu’s mother left when she was 2. Growing up, she turned to novels like ‘The Bluest Eye’ and ‘Song of Solomon.’