The parents of a man who murdered his ex-wife two years ago have been granted permanent custody of the young couple's two children by a Prince William County judge, over the protests of the victim's parents, who also sought custody.

Michele Quiles had agreed to let the girls, now 6 and 4, stay with their father, Marlo L. Small, after their divorce. But in 2002, Quiles decided she wanted custody. On April 24 of that year, Small lured Quiles, 24, to a dark road in Annandale, handed her some photos of their children at a Chuck E. Cheese's birthday party and then shot her in the head.

For two years, Small and his daughters lived with his parents, Evelyn and Keith Small, in Woodbridge. Marlo Small denied killing his ex-wife and prevented her parents from seeing their granddaughters. But in July 2003, Small was arrested. The 31-year-old pleaded guilty in January to second-degree murder and was sentenced to 38 years in prison.

The situation created what family lawyers said was apparently unprecedented in Virginia law: a custody battle between two sets of grandparents after a domestic homicide.

And after a day-long hearing Monday, Prince William Circuit Court Judge Rossie D. Alston awarded sole legal custody of the girls to the Smalls. But the chief judge also ruled that Quiles's parents and sister had a legitimate interest in the girls and established regular visitation for them.

"The Quiles family is deserving of something more than traditional 'visitation,' " Alston wrote in a draft order given to both sides, adding that "it is in the best interest of the children for all parties to have custodial care rights."

Alston granted the Quileses visitation every third weekend as well as every weekend with a Monday federal holiday. He also granted the Quileses a pair of two-week visits in the summer, one "bonus week" and parts of the Thanksgiving and Christmas holidays every year.

The Quileses were crushed. The Smalls were quietly satisfied.

"He took my daughter, then he took my granddaughters," Jeanne Quiles said of her former son-in-law.

"This was his big plan," said Evelyn Quiles, Michele Quiles's sister. "If he was going to get caught, keeping those kids with them [his parents] and racking up that time with them" so the Smalls would get custody. "The whole thing was a setup."

Evelyn Small, Marlo Small's mother, said, "These children have always been safe and secure. They've been in a loving, nurturing family, and they will continue to be. We've always had their best interests at heart."

Family lawyers said the judge's ruling was not surprising. The focus of a judge's decision in a custody case is the best interests of the children, they said, not the circumstances behind their family's implosion. The Quiles girls have been living with the Smalls since 2001.

Joseph A. Condo, a divorce lawyer in Tysons Corner and former Virginia State Bar president, said the Quileses "would have to have demonstrated the kids are not doing well in the current circumstances." He acknowledged that awarding the girls to the parents of their mother's killer "is counterintuitive to the layperson. But his [Small's] case is probably immaterial to the analysis of what's in the best interest of the kids. Everything else gets squeezed out."

The Smalls live in a spacious house in Woodbridge, while Jeanne Quiles, who is separated from her husband, and Evelyn Quiles live in adjacent apartments in Alexandria. Keith Small is a lawyer whose income is greater than the Quileses'.

Susan M. Hicks, a divorce lawyer in Fairfax City, said that in a judge's analysis, the Smalls would benefit from having had the children for a significant period of time. "Stability of the parents is what judges consider," Hicks said. "I tell my clients that what's been happening in the past is the most likely thing to happen in the future, unless you can think of a good reason to upset the apple cart."

The Quileses were surprised to see Judge Alston appear on the bench Monday rather than Judge William D. Hamblen, who had been handling the case for more than a year. Ruben Quiles, Michele Quiles's father, said that a new judge couldn't immediately grasp the complexities of the case and that Alston "didn't take all of the testimony into account."

Ruben Quiles noted Evelyn Small's earlier testimony that the girls are in day care from 7:30 a.m. to 5:30 p.m. daily. He said that small children don't need 10 hours of day care and that his wife was available every day.

"One of her offspring is a murderer," Ruben Quiles said of Evelyn Small. "These children are experiencing the same upbringing as Marlo, being shipped off to schools, away from the home."

Evelyn Small, who testified that she was unemployed, said the children were being well cared for. "Enough is enough," she said. "Let them live quietly."

The Quileses said an appeal seemed unlikely. They were told the process would take about two years and cost an additional $20,000 in legal fees. Condo said that an appeals court would focus mainly on whether Alston abused his discretion and that he doubted Alston's ruling would be reversed on appeal.