When we consider the differences between men and women, thinks Jonathan Perry, the remarkable doctor of E.J. Levy's new novel, we lose sight of similarities too easily. "Once the skin is peeled back, the distinctions are few," Dr. Perry says. "Save for the reproductive organs, one cannot tell man from woman — one cannot say This is a woman's brain or lungs, a man's heart. They think and beat just the same."

What is different, the good doctor understands intimately, are the limitations and demands that society forces on women, especially in (but not limited to) the 19th century. Dr. Perry knows these restraints are drivel, because before he became Jonathan, he was Margaret, a poor Irish girl who would have been left to the streets had she not disguised herself as a man.

Inspired by the true story of Dr. James Barry, who was born Margaret Anne Bulkley in 1795 in Cork, Ireland, "The Cape Doctor" arrives as we continue to wrestle with questions about gender that should have been settled long ago. Though it's a compelling story of one particular transformation, this wise, emotionally resonant novel makes an intelligent, heartfelt plea for compassion as it sifts through the wrongheaded assumptions we make about identity.

Author of the story collection "Love in Theory," which won the 2021 Flannery O'Connor Award, Levy re-creates the perfect storm of patronage that allows Margaret to be educated at the hands of Gen. Fernando de Mirandus, the friend of an uncle. The general conceives the plan of turning Margaret into Jonathan — he sees something in her and knows she will excel at medicine.

And so she — he — does. Margaret becomes Jonathan with a few stumbles, then swiftly. The freedom is intoxicating, the best discovery "that greatest liberty of men: not to have to please. To be able to indulge bad temper and dislike, to feel whatever I might. Without apology, I shrugged off sweet disposition like a cloak."

But when Dr. Perry becomes a physician in Cape Town, South Africa, he befriends the governor, Lord Somerton, and suddenly that intoxicating freedom runs up against an entirely different emotion that embroils governor and doctor in a dangerous romantic scandal.

What's most striking about the novel is Levy's fearless depiction of Margaret/Jonathan, her authentic rendering of this voice, her fleshing out of a little-known historical character full of complications. Dr. Perry is brave and forthright but also selfish and jealous, far from idealized. When a chance to live as a woman presents itself, how can she give up all she has earned? How can anyone bear to give up "the liberty of my own mind"?

"The Cape Doctor" is ultimately a love story, but not only in the traditional sense. It's about loving the freedom to be your real self. "To be seen truly is the greatest gift," Perry says. It's a lesson we still haven't learned.

Connie Ogle is a book critic in Florida.

The Cape Doctor
By: E.J. Levy.
Publisher: Little, Brown, 352 pages, $25.95.
Event: In conversation with Rebecca Makkai, 7 p.m. June 22, livestreamed on Magers & Quinn Facebook page and YouTube channel.