A 35-year-old Honduran pastor fleeing death threats from gangs in his native country sought asylum in the U.S. but was told eight months ago he had to wait in Mexico because of a Trump administration policy.

Earlier this week, Douglas Oviedo's eyes filled with tears as a San Diego judge told him he had won: He could stay legally in the United States as a refugee.

The young pastor was among the first asylum seekers sent back across the U.S. southern border under the Trump administration’s remain-in-Mexico policy — which has since expanded to more than 40,000 migrants waiting in dangerous and overcrowded conditions in border towns.

He is also one of only a few to have won asylum since the new policy took effect in January, his lawyers said.

“I’m so thankful to God,” Oviedo told NBC News in Spanish after the judge's ruling this week. “I’m just so happy to know all my sacrifices, all the tears in the night, all of the suffering, has turned into a great reward.”

At the same time, he said he is concerned about the “thousands of migrants on the other side of the wall who are looking for the same opportunity.”

Douglas Oviedo Jenna Schoenefeld / for NBC News

Oviedo fled repeated death threats from Honduran gangs because of his religious ministry as well as his community political activism. He made the journey north to Tijuana with the massive migrant caravan that garnered global attention last fall.

“There was a lot of discrimination, xenophobia but also a lot of humanitarian help from people with good hearts, but it wasn’t easy to leave behind our land, our people, our families in Honduras,” he said.

“Soon it wasn’t just single men and women, it was entire families, women and children, and that’s what breaks your heart,” he said.

One day while he was at the beach in Tijuana, Oviedo thought of the thousands of other migrants who were waiting in Mexico and approached another Honduran migrant named Michael Rodriguez about starting a shelter by migrants for migrants.

“The shelters are saturated, there’s nowhere to stay, especially for the women and children who are the most vulnerable,” he said.

In response to the lack of space in Tijuana’s migrant shelters, Oviedo and Rodriguez led the construction of Casa Hogar del Puente, a shelter for migrant women and children under the remain-in-Mexico program, working on finishing the shelter even as Oviedo's final hearing approached.

“I can say this has changed my life as a migrant, as a person, as a better father, as a better man," he said. "To now have a shelter that’s going to house a lot of people, that my people from Central America will be OK."

Oviedo said migrants were very vulnerable to violence or extortion while in Mexico, and much of his time spent in Tijuana was spent in fear. His own friend went missing on the journey north.

“I had a friend that up until this day I am still looking for,” he said. “We haven’t been able to find him anywhere. I pray to God my friend is OK.”

Oviedo said he has been in contact with the man’s family in Honduras, but they have not heard from him either.

Even now in the United States, Oviedo has stayed on as the general director of the shelter, supporting Rodriguez and the other migrants in Tijuana to keep it running as it neared construction. The shelter will eventually have space for about 40 migrants, he said.

In addition to finishing the shelter, he now has another goal too: finding lawyers for other migrants like himself.

“I will do everything I can, work day and night to find them lawyers to give them legal representation,” he said. “That’s what hurts me so much. I won and I am here but I was privileged to have a lawyer in court that was with me.”

Lisa Knox, Oviedo’s attorney, said Oviedo is one of a handful of migrants known to have won asylum under the remain-in-Mexico policy for several possible reasons, including that some might not be making it as far in the process because of the hardship of surviving in Mexico and making it to their court dates.

The Trump administration has defended the policy as necessary to weed out “fraudulent” asylum claims amid the influx of Central American families coming to the border. Critics say the policy puts migrants in danger and could keep out those with valid claims.

“A lot of people just aren’t making it to court and are giving up. That’s by design. The program is making it so difficult,” said Knox, who is with the Centro Legal de la Raza.

Those with valid claims still have a difficult time accessing counsel because of the policy keeping them in Mexico and may be unable to convince a judge on their own, she said.

Oviedo and Knox said the youth pastor preached in one of the most dangerous neighborhoods in the Honduran capital of Tegucigalpa, going out into the community to convince young people to leave or not join the gangs in a country where warring factions have led to massive and frequent violence. He was also politically active in organizing his community.

“The gangs saw him as a threat and threatened him many times,” Knox said.

After months of uncertainty, on Monday, Judge Rico Bartolomei granted Oviedo asylum.

“He’s been such a leader in his community, him winning his case is important, for folks to see that it is possible,” Knox said.

The government has a month to appeal the judge’s decision and if that happens the case will be brought before the Board of Immigration Appeals.

But if his asylum is finalized, Knox said Oviedo can then petition to bring his immediate family to the United States with him.

Oviedo is hopeful he can bring his wife and three children, a 10-year-old son, 7-year-old daughter and 4-month-old baby, with him to California.

While it has been hard for them to be apart, Oviedo said his family was joyous after the news that he won his case.

“I told them very soon you will be here with me in the United States and you won’t have to suffer what I suffered,” he said. “This is for them.”