She ended up finishing the race in just under three hours, a result that disappointed her. The morning’s rainstorms had made the trails slick with mud and she had fallen twice.

Her friend, Fredelyn Alberto, 30, a fellow Filipino domestic worker, came third in the full race of 21.5 miles. Ms. Alberto has established herself as one of the city’s rising female trail runners after a string of podium finishes, including winning a 27.9-mile ultramarathon in January. Ms. Pagarigan ran her first ultramarathon in February, a grueling race covering 50 kilometers, or about 31 miles, and she is training for several more.

When they are not on the trails, Ms. Pagarigan and Ms. Alberto are among Hong Kong’s 380,000 foreign maids, who make up 5 percent of the population but play an outsize role in the city’s economy. Foreign maids first arrived in the city in the 1970s, when there was a shortage of local full-time housekeepers as the economy began to take off in line with China’s opening up.

The steady flow of migrant workers has allowed large numbers of local women to stay in the work force and has paved the way for Hong Kong’s transformation into a thriving service economy. Last year alone, foreign maids added $12.6 billion to the city’s gross domestic product, according to a recent report by Enrich, a nonprofit that works on the welfare of migrant workers in Hong Kong, and by Experian, a credit reporting bureau.

And yet the workers often face discriminatory treatment. The authorities have denied foreign maids the right to apply for permanent residency and have mandated that they must live in their employers’ homes — an arrangement critics argue increases the risk of abuse. It is not uncommon for domestic workers to be made to sleep in bathrooms, storage rooms or closets.

Trail running has emerged as something of an unlikely equalizer for domestic workers. For at least a few hours, the sweat and camaraderie of the trails blur the lines between employers and maids, and among locals, migrants and expatriates.

“On weekdays, people say, ‘Oh, you’re a domestic helper,’” Ms. Alberto said. “On weekends, on the trails, they say, ‘Oh, you’re a good runner.’”