Refugee advocates are taking legal action in the hope of striking down a longstanding pact between Canada and the US that has prompted thousands of asylum seekers to brave freezing temperatures, fields of waist-deep snow and icy rivers to cross into Canada by foot.

Since the start of the year, more than 3,000 people in the US – many of whom are anxiously fleeing Donald Trump’s crackdown on immigrants – have entered Canada at remote, unguarded locations along the border. By doing so they aim to skirt a 2004 agreement between Canada and the US that forces most migrants to apply for asylum in the first country in which they arrive.

Advocates have long warned that the pact, known as the Safe Third Country Agreement, encourages migrants to take long, riskier routes to enter Canada and file claims inland, where the agreement does not apply.

On Wednesday, after months of unsuccessfully pressing the Canadian government to consider suspending or rescinding the agreement, three advocacy groups took their battle to court.

“The US was never safe for all refugees, and is now even less safe,” said Loly Rico of the Canadian Council for Refugees, one of the groups backing the legal challenge. “It is wrong, morally and legally, to send claimants back to the US, knowing as we do that they may face serious violations of their basic rights.”

Along with Amnesty International and the Canadian Council of Churches, Rico’s group has joined a court challenge filed by a woman who fled to the US from El Salvador in November.

The woman – whose name is being withheld to protect her identity – and her two daughters attempted on Wednesday to seek asylum in Canada at a border crossing.

She worried that filing a refugee claim in the US would come with a higher risk of being detained and eventually deported to her home country, where she was terrorised by a gang whose members raped her and threatened to kill her family.

The Safe Third Country Agreement meant her application was automatically rejected. Soon after she filed a federal court challenge of the agreement and lawyers are now pushing to allow her and her daughters to stay in Canada while the months-long challenge is heard.

On Thursday, Canada’s ministry of immigration, refugees and citizenship responded to the legal challenge, saying it continues to stand by the agreement and describing it as an “important tool” to manage refugee claims made in Canada and the US.

“Similar agreements are used by countries around the world to deter against ‘asylum shopping,’ and control pressures on asylum systems,” a spokesperson from the ministry said in an email. “Canada has carefully analyzed recent developments in the United States, including the executive orders related to immigration and refugee matters, and determined that the US remains a safe country for asylum claimants to seek protection there.”

This week’s court challenge marks the second time that advocacy organisations in Canada have taken on the Safe Third Country Agreement. The first challenge, launched shortly after the agreement came into effect in 2004, saw a federal court judge rule that the US was not safe for refugees and move to quash the agreement. The Canadian government successfully appealed the decision on a technicality and the country’s supreme court declined to hear any further appeals.

“Those concerns that were raised in 2004 remain, and in many ways have gotten worse,” said Gloria Nafziger of Amnesty International, pointing to recent steps taken by the Trump administration to significantly expand the detention and expedited removal of migrants.

She described Trump’s actions as being symptomatic of a broader move by many countries around the world to close their doors to refugees.

According to the Royal Canadian Mounted Police 3,461 asylum seekers were intercepted in the first six months of the year.