Jessica Port and Virginia Anne Cowan had settled on San Francisco as the place to turn their two-year engagement into a marriage, taking advantage of an opportunity in 2008 for same-sex couples to wed there.

They flew from their home in the District of Columbia, had a courthouse ceremony and played tourist in the city for a few days.

Two years later, the relationship in tatters, Port filed for divorce in Maryland, where she had bought a home. The women had already divided their belongings, didn't hire lawyers, and they remained on terms so amicable that "we sat right next to each other at the divorce hearing," Port recalled.

A year and a half after that, they're still not divorced, adrift in legal limbo. A Prince George's County judge refused their request for an uncontested divorce, and their case is wending its way through the courts.

For same-sex couples, calling it quits can be harder than saying "I do."

While they are gaining the right to marry in an increasing number of states that have become magnets for same-sex nuptials, the couples are finding that divorce is often uncharted legal territory.

About 40 states do not recognize same-sex marriages, though some allow civil unions or domestic partnerships. Legally tethered, estranged couples may be able to make health care decisions for each other. And neither can remarry without risk of being considered bigamists.

"Am I ever going to get divorced? How am I going to live my life without this piece of paper?" said Port, a 29-year-old counselor for at-risk high school students who has spent sleepless nights pondering the problem. "I want to have a home, I want to have children."

While Gov. Martin O'Malley has signed legislation to legalize same-sex marriage in Maryland, the law won't take effect until 2013, and only if it survives an anticipated referendum on the issue in November's election.

Judge A. Michael Chapdelaine, who denied Port's and Cowan's divorce petition, found that the women's marriage in California isn't valid in Maryland, so they can't divorce in Maryland. Lawyers who follow same-sex legal issues say another gay divorce also has been denied in the state.

The Court of Appeals, Maryland's highest court, is scheduled to hear the case of Port and Cowan next month, and a ruling could set a precedent that all judges must follow. The ruling is expected to have broad implications, as marriage affects so many aspects of life, from pensions to property ownership.

"The only thing worse in my mind than not being able to get married is not being able to get divorced," said California lawyer Frederick Hertz, whose most recent book on same-sex unions is "Making It Legal: A Guide to Same-Sex Marriage, Domestic Partnerships & Civil Unions."

Hertz estimates that about half of all same-sex nuptials are performed for out-of-state couples.

A few same-sex divorces have been granted in Maryland. They include one in the same courthouse where Port and Cowan were turned down. In Baltimore, one judge granted a divorce, while another city judge denied a same-sex couple using Chapdelaine's reasoning, according to lawyers who are familiar with the cases. And a Calvert County judge recently signed a divorce for a same-sex couple, said E. Burton Hathaway III, an Annapolis attorney representing one of the women.

"This is a county-by-county, jurisdiction-by-jurisdiction, judge-by-judge decision," said Michele Zavos, a Silver Spring attorney who is representing Port in the appeal.

"We think what needs to happen is that the Court of Appeals needs to recognize these marriages," Zavos said.

The legal landscape can be confusing. Maryland Attorney General Douglas F. Gansler, who has advocated for approval of same-sex marriage, issued an advisory opinion in 2010 saying that Maryland should recognize same-sex marriages performed in other states. But while the opinion meant that state agencies extended to same-sex couples benefits that heterosexual married couples enjoy, it did not hold sway over courts.

"Divorce is one of the areas that brings to light how there is no alternative to recognizing out-of-state same-sex marriages," Gansler said.

Gansler predicted that the Court of Appeals would recognize same-sex marriages performed elsewhere, as the court generally recognizes marriages in other states — including some that could not take place in Maryland, such as common-law marriages, which are not recognized in the state.