“TO THOSE fleeing persecution, terror & war, Canadians will welcome you, regardless of your faith.” Canada’s prime minister, Justin Trudeau, sent that tweet in January 2017, after President Donald Trump temporarily barred refugees from the United States. Now Canada is sending a cooler message. “There are no guarantees you can stay in Canada,” tweeted the immigration department last month.

The tone changed because too many migrants interpreted Mr Trudeau’s welcome as unconditional. Some 20,000 asylum-seekers walked over the border from the United States last year, a nearly tenfold rise from 2016. About 7,500 came in the first four months of 2018.

Under a “safe third country” agreement between Canada and the United States, implemented in 2004, Canada should turn back asylum-seekers crossing over from its southern neighbour. It requires them to seek asylum in the first safe country they reach. But recent border-crossers are taking advantage of a loophole: the agreement applies to those who come by air or train or cross at one of the 119 border posts. If they get in another way, Canada has to let them stay while it processes their claims.

Now the most popular way in is to take a taxi to a spot near Champlain, a town in northern New York state, then hop across a ditch into Quebec, Canada’s French-speaking province. In April 2,500 asylum-seekers entered Canada this way.

Among all claimants, the biggest group last year was Haitians (see chart). Some came after Mr Trump withdrew the “temporary protected status” they received after an earthquake in Haiti in 2010. American citizens, many the children of undocumented immigrants, were the third-biggest group. This year Nigerians top the ranking.

At first Canadians enjoyed feeling morally superior. Then they started to worry that most asylum-seekers were really economic migrants. The opposition Conservatives accused the government of losing control of immigration. Such claims threaten the consensus that underpins Canada’s immigration policy, which remains generous. This year it plans to admit 310,000 immigrants and refugees, equivalent to 0.8% of its population.

Asserting control means sounding tough. Avoiding border posts “is no free ticket to Canada”, said Ralph Goodale, the public-safety minister, on May 7th. Asylum-seekers will be arrested before officials consider their claims, he warned.

The surest way to solve the problem would be to close the loophole in the third-country agreement. There are rumours that Canada has proposed this to the United States. Mr Trump is unlikely to support a deal that would keep more asylum-seekers in the United States. Canadian NGOs have challenged the existing agreement in court, saying that the United States no longer qualifies as a safe country. Mr Trudeau may wish he could build a wall.