TOKYO — A visit to Japan by Pope Francis and his dream of a nuclear-free world drew largely positive headlines this week in Japan. But when he tried to gently encourage the Japanese to extend a hand of friendship to refugees, the backlash on social media was significant.

Japan, among the world’s richest nations, has some of the toughest policies toward refugees and asylum seekers and a reputation for being relatively closed to outsiders. The pope’s effort to preach a more accepting message was not universally welcomed.

“In a special way, I ask you to extend the hand of friendship to those who come here, often after great sufferings, seeking refuge in your country,” he said, in a speech to a group of 900 mostly young people, including some Kurdish refugees.

“Indeed, a small group of refugees is present with us here, and your kindness to them will show that they are not strangers. Not in the least, for you regard them as brothers and sisters.”

The story was one of the most read on the TV Asahi website on Tuesday and Wednesday, and tweets with the words “accept refugees” were trending.

But the response seemed more negative than positive.

“Do that first in the Vatican,” wrote @Ryounagasugi7 in a tweet liked by 14,600 people and retweeted 4,700 times.

The words “impossible” or “absolutely impossible” were prominent.

“That wish we cannot accept. Impossible,” tweeted Kazuo Ishikawa, a policy analyst and a former government official.

A college student with the handle @aign1218 tweeted: “There is little we can do as we don’t have a system to support them. Japanese people have only negative images of refugees. It would be impossible unless that is addressed.”

Others highlighted Japan’s other social problems, including the costs of coping with a rapidly aging society, but some were more blunt in rejecting the pope’s message.

“I am sorry. We’ve seen how European countries have failed terribly. Even so, do you still say that? First of all, we are not a country where Christians are dominant. Would you please ask other ‘Christian countries’? Such as America, or America, or America,” tweeted @no_problem666.

After seeing the flood of negative comments, a group of volunteers who support asylum seekers detained at a facility in Ushiku, north of Tokyo, called on Twitter to act.

“Tweets that would inflame refugee-phobia, xenophobia are growing. [Twitter Japan] should deal with it as its own platform has been used to inflame xenophobia,” the group wrote on its account @freeushiku.