A 29-year-old unwed father can retain custody of his 2 1/2-year-old-daughter, Alexandria Circuit Court Judge Donald H. Kent declared yesterday in a ruling believed without precedent in Virginia.

The child's mother, Betty Cheeks, 23, of rural Halifax County in Southside Virginia, had appealed an earlier lower court decision favoring the father, John Younger of Alexandria, who operates a tow-truck business and works in a fast food restaurant.

Yesterday's decision was the most important victory to date for Younger, who had accused the girl's mother of taking "the only thing I had left" when she walked out of their Northern Virginia home with their infant daughter more than two years ago.

With his ruling, Kent became the first judge of a court of record to rule in favor of an unwed father in a Virginia custody case. The earlier ruling, which attracted wide attention, came from a general district court judge and thus could not be cited by other judges facing the same issue.

"I'm glad it's over," said Younger, who had served as his own lawyer. "It's been almost three years of a mental beating."

When Younger first won custody of his daughter Tonya last August in a decision by District Judge Joseph L. Peters Jr., some legal experts said the ruling appeared to extend the rights of unwed fathers. "They [unwed fathers] now stand substantially in the shoes of wedded fathers," said Doris Jonas Freed, the American Bar Association's top expert on custody law.

Mothers traditionally have been given custody of children in domestic cases, but lately there has been a trend of fathers seeking -- and winning -- custody after claiming they were denied visitation with their children.

It was a dispute over visitation that led Younger to seize Tonya as she walked to the mailbox with her mother in Halifax last June 16, the day after Father's Day. Younger claimed he took Tonya from her mother because he was repeatedly frustrated by Cheeks for two years in his efforts to see the girl.

Kent abruptly ended the trial yesterday, declaring that Miss Cheeks' mother, Lula Mae Farrell, had apparently perjured herself. She testified there had been a shooting incident at her Halifax house, where Tonya lived.

At a previous court hearing, Kent said, Farrell testified there had been no shooting. Farrell's apparently contradictory testimony came as she was being questioned by Michael Jamgochian.

While a stunned Jamgochian stood aside, Judge Kent, obviously angry, said "It appears to me, Mr. Jamgochian, you're impeaching your own witness . . . She may very well subject herself to perjury."

In his ruling, Kent said the contradictory testimony ruled out Virginia's so-called "tender years" doctrine, under which the mother is given custody rights over the father "if all other things are equal."