In 2001, HelenKay Dimon had been practicing law for six years. She worked for a small family-law firm in Rockville, handling divorce cases, adoption suits and, her specialty, custody battles. Every day, she met with couples ready to battle each other to the last dollar and the children caught in the crossfire.

One day, a sympathetic colleague handed a sleep-deprived Dimon three paperback romance novels. “You need a happy ending,” she said.

Dimon devoured the books and soon purchased more. Before long, she was writing her own romances — just a hobby, something to help her relax after a long day of work. Then she stumbled upon an online contest sponsored by the best-selling author Lori Foster. The contest invited amateur writers to submit a few pages of a recent work, and Foster would send the best to her editor. Dimon entered and won.

Those pages eventually evolved into the start of Dimon’s first published work, “Hard Hats and Silk Stockings,” about an architect and a contractor who discover what they think is a panic room while renovating an old house. “It’s actually a naughty room,” Dimon explains. “And the couple gets stuck down there, because of course they do.”

So Dimon switched from couples who could barely restrain themselves from tearing out each other’s throats to couples who could barely restrain themselves from ripping off each other’s clothes. But she’s just one of several lawyers who has moonlighted as a romance writer. (In 2007, Dimon retired from legal work to write full time.) At least four bar-certified lawyers sit on the board of the Romance Writers of America, and several more attend the group’s annual conference.

Heidi Bond, who writes under the pen name Courtney Milan, clerked for Supreme Court Justices Sandra Day O’Connor and Anthony M. Kennedy before writing her first romance. Like Dimon, she first turned to romance novels as a way to take a break from long days of legal research and opinion drafting. While taking a year off to apply for jobs as a law professor, she had an idea for a romance of her own. “ ‘Proof by Seduction,’ ” she remembers. “It was a terrible title — I don’t know why they let me keep it.” The book was about a scientist determined to prove that a fortune teller was a fraud. Spoiler alert: They fall in love.

Bond taught law at Seattle University for three years before quitting to write full time. For her, switching between law and romance felt entirely natural. “One of the skills that makes you a good lawyer is the ability to take a bunch of disparate facts and weave them together into something that tells a story that pulls on the human imagination,” she says. Whether you’re convincing a judge that your client is innocent or convincing your reader that a couple is meant to be, it’s the same skill.

Alesia Holliday, who writes under the pen name Alyssa Day, was working as a trial lawyer in Seattle when she started writing creatively. Writing — which eventually became her full-time profession — gave her a certain advantage in the courtroom. “This one federal court judge said to me, ‘I love when you come before me, because your briefs are always so entertaining,’ ” she remembers.

And just as judges appreciate a brief written like a novel, romance-novel readers love reading about the law. Julie James clerked for the U.S. Court of Appeals and had a shot at becoming partner at a large firm in Chicago before she became a full-time writer. (Julie James is her pen name.) Although she left law to write, law never left her writing. The protagonist of one of her novels, “Just the Sexiest Man Alive,” is an entertainment lawyer who advises a Hollywood heartthrob on his upcoming role in a courtroom drama. In another of James’s novels, “Practice Makes Perfect,” two associates competing to become partner fall in love. Her five-book FBI-U.S. Attorney series explores the Chicago criminal justice system.

Even Holliday, who often writes paranormal romance, hasn’t quite left law behind. Every fantasy universe of her design, she says, has a fully developed political and legal system. “In my world, there’s this whole Supernatural Species Protection Act,” she says. “Some writers look at me like I’m nuts.”

Some lawyer-writers, however, prefer to leave law in the office. Julie Kenner, a former lawyer who practiced civil, entertainment and First Amendment litigation, says that she’d worry too much about getting a detail wrong if she set her novels in courtrooms. “I’d just want to get so far into the grain that it would be boring for the reader,” she says.

It’s certainly not unheard of for lawyers to write creatively. John Grisham, the author of best-selling legal thrillers, practiced as a lawyer for about a decade before becoming a full-time novelist. But the romance genre tends to raise eyebrows in law offices. When Kenner published her first novel with Harlequin Books, her co-workers teased her about Fabio and bodice-ripping. (Those tropes, all romance writers will tell you, are thoroughly outdated.)

Holliday’s colleagues referred to her burgeoning career as her “little lunchtime hobby.” After she quit to write full time, one lawyer friend assumed she was struggling financially and made a condescending offer to get her some part-time work. “She offered $4,000 dollars,” Holliday recalls. “I was like: ‘Oh, honey, I don’t even roll out of bed for that kind of money.’ ” (For the record, she has published a few dozen novels, many of which are bestsellers.)

Grace Burrowes, who works as a child welfare attorney in rural Maryland, has endured her fair share of teasing, too. (Burrowes is a pen name, but some of her colleagues know about her second career). Yet the same lawyers who tease her often ask, when no one’s listening, if she knows how they might get an agent.

Dimon’s clients had a different request. “The men all tell me that they’re romantic heroes and I should base my characters off them,” she says. (Keep in mind, she was a divorce lawyer).

Dimon and her lawyer-writer friends often joke about these exchanges at Romance Writers of America meetups. Law and romance, they admit, may seem incompatible — but perhaps that’s the point.

“Most people become lawyers because they have a strong sense of justice and fairness,” Bond says. But when you work in the legal system, you realize that even the most fair outcomes often leave both sides financially and emotionally hurting. In romance, on the other hand, the good guys always win.

Burrowes feels similarly. “In the courtroom, you see people who have been dealt very low cards,” she says. “My association with romance is my emotional oxygen canister.”

And that’s the sort of happy ending a lawyer-turned-romance-writer dreams of.