TOKYO -- Samith Hilmy, a 26-year-old student from Sri Lanka, was waiting anxiously at a real estate office in Tokyo as an agent went through the procedure of ringing the Japanese landlord of an apartment the student was interested in renting.

Following a brief exchange, which lasted no more than 10 seconds, Hilmy said, the agent hung up the phone and uttered the same three-word phrase he had heard from a dozen or so agents over a month of home hunting: "Sorry, no foreigners."

When Hilmy first arrived in Japan in April, his Japanese language school set him up in an apartment for six months in Shin-Okubo, a district in the capital's Shinjuku Ward. But he has to leave the place soon, and time is short.

A real estate agency in Tokyo's Shin-Okubo district, an area with a large foreign-born population. (Photo by Tsubasa Suruga)

He said he has also encountered some real estate agents that demanded four to five months' worth of rent up front -- some want a year's worth -- as "insurance" in case he leaves the apartment or the country without notice.

"I felt," he said, "like I was being treated like a criminal."

Hilmy's odyssey is not unlike the reality faced by many foreigners living in Japan. This year, the country released a first of its kind national survey that highlighted the extent of housing discrimination foreigners face.

According to the study, released by the Ministry of Justice in March, out of 2,044 foreign residents who had sought housing within the past five years, 39.3% reported being turned down because they were not Japanese.

The impact is now being felt by employers. In recent years, numerous Japanese manufacturers and services have been trying to make up for the country's shrinking labor force by looking elsewhere for workers. They want to create an inflow of talent, but housing discrimination could become a dam.

As of last October, Japan had 1.08 million foreign workers, up 58% from five years earlier, accounting for around 2% of the total workforce, according to the Ministry of Health, Labor and Welfare.

They have to endure the humiliating phone call that often ends with a "sorry, no foreigners" because some landlords worry about tenants from other countries flying the coop, so to speak.

A few years ago, a 63-year-old landlord from Tokyo's Ikebukuro district who asked not to be named rented an apartment to a male Chinese student. After six months or so, he said, neighbors began reporting that two other men had moved into the same flat, "often making a racket late at night."

When the neighbors confronted the student, the tenant pretended not to understand Japanese. "It made me more hesitant [to rent to foreigners]," the landlord said. "I just don't want any more trouble."

Hiroyuki Goto, CEO of Global Trust Networks, a Tokyo-based guarantor service provider for foreign tenants, said not many landlords have actually had these kinds of experiences but the stories "have spread across the country, causing fear among landlords."

Other reasons include landlords who assume foreign tenants would trouble neighbors -- from Brazilians throwing large home parties and firing up the barbecue to American college students who like partying into the night in their apartments.

Goto said even if prospective tenants are skilled workers with stable jobs at big-name Japanese companies, many housing units remain out of reach.

Total OA Systems -- a Tokyo-based IT consultancy with 200 or so employees, including those in China and the Philippines -- plans to expand the number of its foreign engineers working in Japan. It currently has only a handful.

The IT industry is suffering from a significant labor shortage, and the consultancy was acutely aware of the discrimination problem last year when it welcomed a systems engineer from the Philippines. To dodge any hassles, the company consulted a property agent that caters to foreigners, whom industry players describe as an "underwhelming minority" in Tokyo.

Even real estate agencies with experience helping foreigners run into the same problem: "Almost nine of 10 private housing units in Tokyo do not allow foreign tenants," according to Masao Ogino, CEO of the Ichii Group. "It is still an extremely exclusive market."

Tsuyoshi Yamada, a human resources manager at Total OA Systems, said a lack of sufficient support for non-Japanese employees, including in regard to housing, could throw a hurdle up in front of the company's plan to bring in overseas talent.

This concern is particularly strong for smaller IT companies like Yamada's. "Even if we finally find a promising engineer," he said, "retention could become a problem."

Some companies are taking the matter into their own hands. YKK recently opened a small serviced apartment complex for its foreign-born employees in Kurobe, Toyama Prefecture, central Japan. Its flagship plant is a 10-minute drive away.

The world's leading zipper maker is getting ready to expand into the low-end segments in China and other parts of Asia. To get a head start, it is training more foreign employees who could go on to become managers at these plants and elsewhere. These trainees work stints of up to three years in Kurobe.

The 10 apartments are close to full with engineers from Indonesia and other countries, and YKK is already considering whether it needs more housing for the more than 30 overseas engineers it plans to welcome every year.

YKK's foreign employees used to live in other company dormitories or in private housing rented by the company. YKK said it has not experienced landlords rejecting its foreign-born employees but feels its serviced apartments help these workers avoid cultural quibbles with would-be neighbors.

More serviced apartment units would "allow [the foreign employees] to concentrate on their training from the day after they arrive to Japan," a representative said.

Japan has no law prohibiting landlords from refusing applicants based on ethnicity or nationality.

"Judicially, the only way to resolve such a rejection is through civil lawsuits, which is an extremely high hurdle for foreigners," said Yumi Itakura, an attorney with the Tokyo Public Law Office, citing costly trial fees and a lack of law firms with enough capacity to help non-Japanese clients.

But there have been efforts by industry players to tackle the issue. The Japan Property Management Association, a group of over 1,300 companies handling some 5 million properties, in 2003 created guidelines that include advice for landlords and real estate agencies in dealing with prospective foreign tenants.

"In some countries, a rental contract doesn't require a guarantor [which is common in Japan]," one piece of advice says. "Housing rules differ by country and region, therefore you should carefully explain the values and customs that are behind Japan's housing rules."

For foreign tenants, the association created an "Apartment Search Guidebook," which describes the country's common housing rules in six languages. An example: "Living with people other than those stated in the rental agreement or sub-leasing the property are violations of the rental agreement."

A foreigner takes photos of apartment listings on the window of a real estate agency in Tokyo. (Photo by Tsubasa Suruga)

At the local government level, Tokyo's Shinjuku Ward is a forerunner in trying to tackle housing rental rejections. In 1991, the ward specifically stated in an ordinance that it will "strive to resolve [tenant] discrimination" based on nationality.

The issue is particularly important for Shinjuku, which has the highest proportion of foreign residents in Tokyo. As of Aug. 1, of 341,979 residents, 42,613 were not Japanese, more than 12% of the total. People from 130 or so countries live in the ward.

The ward office provides a weekly consultation session on real estate transactions for foreign residents who are having trouble finding a place to stay. In addition, it has set up a mechanism that offers help to residents in Chinese, Korean, English, Thai, Nepalese and Burmese.

Shinjuku periodically holds liaisons with property agents for better collaboration and smoother information exchanges, according to Shinjuku's housing division. The effort is, in part, to support the elderly, disabled and foreigners, "who tend to be the most vulnerable when it comes to securing housing," said Osamu Kaneko, the division's manager.

According to a survey that Shinjuku conducted in 2015, separate from the justice ministry's study, of 1,275 foreign residents, 42.3% said they had experienced discrimination in Japan. Of those, 51.9% felt discriminated against when looking for housing.

The justice ministry study underscores just how widespread discrimination is in Japan's housing market. But the problem could be about to swell. At least the number of foreign residents in the country is trending up. At the end of 2016, it reached an all-time high, 2.38 million, 77% more than 20 years earlier.

Experts say access to housing in Japan is becoming ever more important as the third largest economy takes steps -- though small ones -- to open its door to more foreigners.

Chizuko Kawamura, a professor emeritus at Tokyo's Daito Bunka University and an immigration policy expert, has proposed that the government set up a specialized body on multicultural initiatives that would make way for foreign resident support systems -- from housing, education, medical access and fair employment.

This is "not limited to housing," Kawamura said. "If our government cannot address the social needs of [foreigners] already living in Japan, we won't be able to support those coming into the country in the future."