Everything about the spellbinding "Learned by Heart" strikes me as nearly perfect. Even its title works in at least two ways: The story takes place in 1805 at a strict girls' boarding school in York, England, where learning by memorization is encouraged. The Manor School's adolescents live in close quarters that promote crushes and heartaches.

Emma Donoghue's gorgeously rendered creation is the real-life love story between Anne Lister (1791-1840) and well-to-do Eliza Raine, born to a British doctor and an Indian woman he never married. Eliza and her sister came to England and were taken in by a white British family after their father sailed back to India.

While little is known about Eliza, much has been learned about Lister in recent decades, as scholars discovered, decoded and published parts of her 5-million-word diaries. "Learned by Heart" gives the two 14-year-old schoolgirls equal time in terms of story and sympathy. The result is even more masterful because of the seeming ease with which it combines the lyrically imagined with the painstakingly researched. The inevitable clutter of historical detail falls away as we inhabit the early world of the Manor School.

The story is remarkable.

Under the school's strict rules, even slight deviations seem like open rebellion, something Lister embraces with gender-neutral gusto, impressing rules-following Eliza, who quickly devotes herself to this remarkable, willful, intelligent creature.

The two — biracial Eliza, product of a "birth from an irregular union," as one teacher nastily describes it, and Lister, who claims gayness has been a "vague, violent longing, since the cradle" — share outsider status.

"Who wants to be ordinary, anyway?" Lister asks.

"Almost everyone!" Eliza responds.

"Let's be a pair of originals instead," says Lister.

Easier said than done, in an era when women's education was a way to promote ladylike behavior and marriage-ability. Same-sex attraction, while no stranger to the English boarding school, still was a form of love that dared not speak its name.

Not to be denied, the girls grow closer, delighting in each other's company. Eliza's "own existence at the Manor has been transformed by a wave of Lister's wand." They give themselves a "marriage" that seems torn from Shakespeare.

Donoghue, who wrote the blockbuster "Room," is superb at capturing the unmediated hearts of love-drenched adolescents: raw, vulnerable, disorienting, almost painfully excitable.

Interspersed letters from Eliza to Lister, 10 years later, show that the girls' closeness did not last, which steered Eliza into life-altering circumstances.

The novel's myriad pleasures include a student outing to see "As You Like It," with a traveling actress in the Rosalind role.

To Lister and Eliza, it was as if "this play from two hundred years ago is somehow blabbing their secrets." Back in their icy dorm and too excited to sleep, they enter the more-than-roommates phase in scenes Donoghue handles with both sublime sensitivity and stirring eroticism.

Wise beyond their years, the girls are aware others will not look kindly on their romance: "What can it mean, for the two of them to be in love? Nothing that needs explaining to them; nothing they could explain to anyone else."

The novel's epilogue, a letter from Eliza to Lister, collapses 10 years since the girls left the Manor School. It's almost unbearably sad until we realize, with relief, that Eliza's intelligence has helped her add insight to heartbreak. She will, we fervently hope, survive.

Claude Peck is a former Star Tribune columnist and editor.

Learned by Heart

By: Emma Donoghue.

Publisher: Little Brown, 336 pages, $28.