A gay Montgomery County resident is entitled to a legal hearing to challenge a court order that forced his partner to move out of their shared house as a condition for retaining custody of his son, a Maryland appellate court has ruled.

The decision Monday by the Court of Special Appeals reversed a lower court that had dismissed his challenge, handing a victory to gay rights activists. The appellate court did not, however, rule on the propriety of the restriction itself. The restriction was imposed in 2002 by a judge in an Alexandria family court before the men moved to separate apartments in Rockville.

The appellate court found that the father, Ulf Hedberg, was improperly denied a hearing by a judge who found that there had not been a change of circumstances that would warrant revisiting the custody arrangement. Hedberg argued that there had been such a change, in part because of the absence of his partner, which Hedberg said had left his son, 12, unhappy and sometimes tearful.

The restriction remains in effect pending a hearing in the trial court.

"The decision is an important step in getting a family back together again," said Hedberg attorney Susan Sommer of the Lambda Legal Defense and Education Fund.

An attorney for Hedberg's former wife, Annica Detthow, told the Associated Press that he expects to prevail at the trial court.