A judge has ruled in favor of a family fighting for the right to bury a 20-year-old man who died while under the care of the state.

James Fofanah died on the side of the road in Garland. Police say he was hit by a car and killed when he stopped to help a stranded driver.

"He died as a hero ... and he'll be buried as a hero," said Foday Fofanah, James' older brother.

But arranging for a burial has proven a complex and painful process for his biological family.

Foday said he was the caretaker for as many as 12 children, including James, after his family escaped violence in their native Sierra Leone.

In 2011, Child Protective Services got involved and removed James from the home. He was placed in foster care, and at the time of his death, still under the care of the state.

RELATED: Family battles state to bury young man killed in crash

"Throughout the life of the case, it was never clear to CPS really what relationship these folks had to him and we didn't feel that CPS had the right to make that decision," said Marissa Gonzales, a spokeswoman for the Department of Family and Protective Services.

The Fofanah family took the battle to court and were able to block a burial by the state.

Tuesday morning, in the 298th district court, lawyers for CPS told a judge they removed James from an abusive home and needed guidance on who could serve as James' next of kin.

The judge didn't want to revisit allegations of abuse. Instead, he asked witnesses be called to establish a relationship between James and his biological family.

From the stand, Foday testified that in his culture, the oldest child becomes the caretaker.

"I've been his dad since he was 4-months-old," he said.

The judge agreed and ruled in favor of the Fofanah family.

RELATED: Drunk driver accused of killing driver, Good Samaritan on 635 in Garland

"I just wanted to bury my young one," Foday said. "I just wanted to bury my son and I'm going to have the chance to do that."

A young man that will now be buried by his biological family following their African tradition.

And no matter how complex his life, his family and the court made it clear he died to help a stranger.