A proposed law that would make it slightly easier for foreigners to get a permanent residency in China set off a slew of racist and xenophobic backlash on Chinese social media, that eventually spilled over to Twitter.

But the U.S. social media company says many of those tweets do not violate its policies and some remain online.

The posts, which use offensive language and racial slurs, are a response to a proposed legislation at the end of February by Beijing that appears to ease some of the requirements for foreigners to get a permanent residency or so-called "green card" in China.

With the proposed law, China is looking to attract overseas workers in areas such as science and technology, people with big investments in the country and talent to fill shortages in the economy.

"From this exposure draft and this broadened eligibility criteria, we see the intent of the Chinese government to attract more foreign talents through a long-term working period in China," Dezan Shira & Associates, a professional services firm helping companies do business in Asia, said in a recent article.

The company noted that "stringent criterion" still apply,however.

Despite this, Chinese "netizens" — or people on social media — were up in arms about the proposal. A hashtag that translates as "regulations on the administration of permanent residence of foreigners," was widely-used on Weibo, a microblogging site in China. But that hashtag and posts related to it were quickly banned on the service by the country's censors.

The conversation moved onto Twitter, using the same hashtag.

Several tweets, directed at black people and Africans, used the "N word." A couple of these tweets had been taken down, but several still remain. CNBC cannot show these tweets here due to the offensive and racist language.

Others were more subdued.

TWEET 1: We really don't want you to live in China. China has not been an immigrant country since ancient times. We don't have racial discrimination. We just feel that our country has the right to say no

TWEET 2: 5000 years of Chinese civilization,,China has 1.4 billion people, I don't want China to be the second "France"

A spokesperson for Twitter declined to comment when contacted by CNBC.

Twitter's hateful conduct policy says users "may not promote violence against or directly attack or threaten other people on the basis of race, ethnicity, national origin, caste, sexual orientation, gender, gender identity, religious affiliation, age, disability, or serious disease. "

"We prohibit targeting individuals with repeated slurs, tropes or other content that intends to dehumanize, degrade or reinforce negative or harmful stereotypes about a protected category," the policy reads.