The Safe Third Country Agreement (STCA), in place since 2004, requires refugee claimants to request protection in the first safe country they reach.
But on Wednesday, a judge declared the deal unconstitutional due to the chance that the US will imprison the migrants.
The ruling marks a major victory for Canadian immigration activists.
Lawyers for refugees who had been turned away at the Canadian border had challenged the agreement, arguing that the US did not qualify as "safe" for asylum seekers.
Nedira Jemal Mustefa, one of the refugees forced to remain in the US, told the court her time in US solitary confinement was "a terrifying, isolating and psychologically traumatic experience," according to the court ruling.
"We're all too familiar with the treatment that the US metes out to asylum seekers," Maureen Silcoff, president of the Canadian Association of Refugee Lawyers, told Reuters news agency.
The 5,525 mile (8,891 km) US-Canada border is the longest border between two countries in the world.
The Safe Third Country Agreement is a policy implemented to better manage refugee claims and to avoid so-called "asylum shopping" between countries.