RUIRU, Kenya — Before last year, Richard Ochieng’, 26, could not recall experiencing racism firsthand.
Not while growing up as an orphan in his village near Lake Victoria where everybody was, like him, black. Not while studying at a university in another part of Kenya. Not until his job search led him to Ruiru, a fast-growing settlement at the edge of the capital, Nairobi, where Mr. Ochieng’ found work at a Chinese motorcycle company that had just expanded to Kenya.
But then his new boss, a Chinese man his own age, started calling him a monkey.
It happened when the two were on a sales trip and spotted a troop of baboons on the roadside, he said.
“‘Your brothers,’” he said his boss exclaimed, urging Mr. Ochieng’ to share some bananas with the primates.
And it happened again, he said, with his boss referring to all Kenyans as primates.
Humiliated and outraged, Mr. Ochieng’ decided to record one of his boss’s rants, catching him declaring that Kenyans were “like a monkey people.”
After his cellphone video circulated widely last month, the Kenyan authorities swiftly deported the boss back to China. Instead of a tidy resolution, however, the episode has resonated with a growing anxiety in Kenya and set off a broader debate.
As the country embraces China’s expanding presence in the region, many Kenyans wonder whether the nation has unwittingly welcomed an influx of powerful foreigners who are shaping the country’s future — while also bringing racist attitudes with them.
It is a wrenching question for the nation, and one that many Kenyans, especially younger ones, did not expect to be confronting in the 21st century.
Kenya may have been a British colony, where white supremacy reigned and black people were forced to wear identification documents around their necks. But it has been an independent nation since 1963, with a sense of pride that it is among the region’s most stable democracies.
Today, many younger Kenyans say that racism is a phenomenon they largely know indirectly, through history lessons and foreign news. But episodes involving discriminatory behavior by the region’s growing Chinese work force have unsettled many Kenyans, particularly at a time when their government seeks closer ties with China.
“They are the ones with the capital, but as much as we want their money, we don’t want them to treat us like we are not human in our own country,” said David Kinyua, 30, who manages an industrial park in Ruiru that is home to several Chinese companies, including the motorcycle company where Mr. Ochieng’ works.
Over the last decade, China has lent money and erected infrastructure on a sweeping scale across Africa. To pay for such projects, many African nations have borrowed from China or relied on natural resources like oil reserves. And when tallying the cost, African nations have generally focused on their rising debts, or occasionally on the exploitative labor practices of some Chinese firms.
But here in Nairobi, concerns about racism and discrimination are a growing part of the conversation about China’s expanding presence.
In Nairobi, workers in their 20s and 30s swap stories of racism or discrimination they have witnessed. One described watching a Chinese manager slap her Kenyan colleague, who was also a woman, for a minor mistake.
Other Kenyan workers explained how their office bathrooms were separated by race: one for Chinese employees, the other for Kenyans. Yet another Kenyan worker described how a Chinese manager directed his Kenyan employees to unclog a urinal of cigarette butts, even though only Chinese employees dared smoke inside.
The Chinese population in Kenya is difficult to count accurately, although one research group put the figure at around 40,000. Many are here for just a few years, to work for one of hundreds of Chinese companies. Many of the employees live together in large housing developments and are bussed back and forth from work, leaving little social interaction with Kenyans.
“Because of the isolation and lack of integration, usually they are not very aware of the local situation,” said Hongxiang Huang, a Chinese conservationist and former journalist who has lived in Nairobi. “They do not know very well how to interact with the outside world.”
And many arrive with hierarchical views of culture and race that tend to place Africans at the bottom, said Howard French, a former New York Times correspondent who wrote the 2014 book “China’s Second Continent,” which chronicles the lives of Chinese settlers in Africa.
Accusations of discrimination have even emerged on a major state-sponsored project: a 300-mile Chinese-built railroad between Nairobi and Mombasa. The train has become a national symbol of both progress and Chinese-Kenyan cooperation, though positive reviews have at times been overshadowed by concern over its $4 billion price tag.
But in July, The Standard, a Kenyan newspaper, published a report describing an atmosphere of “neocolonialism” for Kenyan railway workers under Chinese management. Some have been subjected to demeaning punishment, it said, while Kenyan engineers have been prevented from driving the train, except when journalists are present.
It was a particularly explosive claim because during the train’s maiden voyage, with President Uhuru Kenyatta on board, two Kenyan women drove the train to much fanfare.
In interviews with The New York Times, several current and former locomotive drivers agreed that only Chinese drivers got to operate the train, describing a range of racist behavior.
“‘With uniforms on, you won’t look like monkeys anymore,’” Fred Ndubi, 24, recalled his Chinese supervisors saying. Two other workers with him offered the same account.
Mr. Ndubi, who has since left the railroad, said his family had sold about a quarter of its land so he could afford the training needed to become a train operator.
“We just stood there and asked him, ‘How can you call us monkeys?’” Mr. Ndubi recalled.
Sometimes, the racial controversies have unfolded in full public view. Two years ago, a laundry detergent company in China ran a television commercial in which the detergent’s effectiveness was demonstrated by transforming a black man into a light-skinned Asian man. Last year, WeChat, the country’s popular messaging app, apologized after its software was found to translate the Chinese words for “black foreigner” into a racial slur in English.
This year, China’s televised Lunar New Year gala, estimated to reach 800 million viewers, included caricatures of Africans, with blackface and men in animal suits.
When asked about the controversy, China’s foreign ministry spokesman suggested that Western news organizations had blown the matter out of proportion in an effort to “sow discord in China’s relations with African countries.”
Mr. French, the author of “China’s Second Continent,” said that when it comes to Africa, China has had a tendency to dismiss criticism of its conduct by noting that the West, not China, fueled the slave trade and colonized the continent.
But that misses the point, Mr. French said, by ignoring the treatment of Africans today.
“Their experience is that they are being treated in flagrantly disgusting, racialized ways,” Mr. French said.
Kenya, home to more than 40 officially recognized ethnic groups, has long had its own problems with prejudice and ethnic tensions. A disputed election in 2007 led to several weeks of mass violence, much of it along ethnic lines. And Kenyans of Indian and Pakistani descent have long felt secluded from mainstream Kenyan life, although the government has granted them greater official recognition.
But the Chinese presence has added a volatile new element and, at times, the Kenyan government has seemed divided over how to respond. When allegations of discrimination by Chinese employers emerged over the summer, a Kenyan government spokesman suggested that part of the problem lay instead with Kenya’s national work ethic, which he said might need to change.
There are signs that elements within the government may be pushing back. Last month, the Kenyan police raided the Nairobi headquarters of a Chinese state-run television channel, briefly detaining several journalists. The timing struck many as curious: It was the same week that President Kenyatta was in Beijing, raising the question of whether someone inside the Kenyan government wanted to create a diplomatic row.
The experience of Mr. Ochieng’ and other workers speaks to the future of relations between the two countries. He took a job as a salesman, thinking it would secure a prosperous future, but when he showed up to work he found a different reality. The pay was a fraction of what he was initially offered, he said, and it was subject to deduction for a long list of infractions.
“No laughing,” was one of the injunctions printed in the company rules. Each minute of lateness — sometimes unavoidable given Nairobi’s notorious traffic — came with a steep fine. An employee who was 15 minutes late might be docked five or six hours’ pay, he said.
One Chinese manager, Liu Jiaqi, 26, loomed particularly large. At times, he was smiling and good-natured, Mr. Ochieng’ said, but whenever the question of pay came up or something went wrong, Mr. Liu turned on his subordinates.
When Mr. Ochieng’ left a sales brochure behind in the car during a sales visit and had to excuse himself to retrieve it, he said Mr. Liu began crowing, “This African is very foolish.”
But the most painful, he said, were the monkey insults — the kind of dehumanization used to justify slavery and colonization.
Mr. Ochieng’ said he protested several times, but the monkey comments did not stop.
“It was too much,” he said. “I decided, ‘Let me record it.’”
The rant that Mr. Ochieng’ recorded came after a sales trip had gone awry. Mr. Ochieng’ asked his boss why he was taking out his anger on him.
“Because you are Kenyan,” Mr. Liu explained, saying that all Kenyans, even the president, are “like a monkey.”
Mr. Ochieng’ continued that Kenyans may have once been oppressed, but that they have been a free people since 1963.
“Like a monkey,” Mr. Liu responded. “Monkey is also free.”
The day after the video began to circulate widely, Mr. Liu, who could not be reached for comment, was deported. It was an especially stark illustration of the clash between the two cultures, with many adding that it produced a noticeable chill in relations between Kenyans and Chinese people in the capital.
“That video had a big effect,” said Victor Qi, the Chinese manager of a noodle restaurant in Nairobi, adding that business from black customers seemed to fall off after that.
After the video emerged, an official with the motorcycle company called Mr. Liu’s behavior an “unfortunate transgression,” while a Chinese Embassy spokesman said, “The personal talk and personal feeling of this young man does not represent the views of the vast majority of Chinese people.”
Mr. Ochieng’ says he has heard stories of colonialism — “what our forefathers went through” — and worries that the Chinese will take Kenya backward, not forward as the nation’s leaders have assured.
“These guys are trying to take us back to those days,” he said in the tiny room he shares with his wife and 2-year-old son. On the wall hung a poster with a verse from Ephesians. Nearby, on a little desk rested two Bibles, both equally dog-eared with use.
“Someday I will tell my son that when you were young, I was despised because I was black,” he said.