In the nightmare that's been haunting Mamadou, he is running through the woods, chased by a figure who wants to kill him.

It has been a recurring dream ever since he was found, barely conscious, by police in the snowy woods near the Lacolle, Que.-U.S. border crossing in the early hours of March 5.

Mamadou huddled under a winter jacket at the immigration detention facility in Laval, just north of Montreal, shivering as he told his story. Tears streamed from his bloodshot eyes.

His feet, swollen and discoloured, are covered in blisters. His hands are too sore to hold a pen.

"I went through hell, I'm telling you, walking," he told CBC News during an interview in a small, sparsely furnished visitor room at the detention centre. "I'm still cold in my body."

A group of refugee claimants from Eritrea cross the border illegally from New York into Canada earlier this month, near the spot where Mamadou crossed. (Ryan Remiorz/Canadian Press)

Mamadou, whose family name is being withheld for his own protection, estimates he had been walking for around nine hours — twice wading into frigid waters — when he finally collapsed in the woods.

"I thought, 'That's OK, I want to die. Let me just die on my way. I don't want to go back,'" he said.

Treacherous trek through the dark

Mamadou, 46, had set out from the American side just after dark on March 4, intent on finding safe haven in Canada as the temperature plunged below –15 C.

It was his second attempt at crossing the border. A few days earlier, he presented himself to Canadian border guards at Lacolle seeking asylum status. He spent two nights there before being turned back.

Attempting to cross legally was a strategic mistake, according to his immigration lawyer.

By doing so, Mamadou became ensnared within the Byzantine provisions of the Canada-U.S. Safe Third Country Agreement, which governs who can make asylum claims and where they can do so.

Brought into effect in 2004, it was meant to prevent "asylum shopping." In practice, say a growing number of lawyers, activists and federal politicians, it simply encourages the type of hazardous crossings that almost cost Mamadou his life.

"The man ended up in the hospital when he tried to cross," said Mamadou's lawyer, Eric Taillefer. "This is a direct consequence of the agreement."

Living in limbo as New York cabbie

Mamadou is a Muslim from Ivory Coast. He watched as rebels shot his father, a prominent businessman in Abidjan, and burned down the family home during the country's bloody civil war.

For the past 10 years, he said, he has been living in the United States, working as a cab driver in New York City.

He lived in a state of legal limbo. His initial asylum application had been rejected when he landed in the U.S. in 2006.

But immigration officials at the time told him it was too dangerous to send him back to Ivory Coast, so they let him stay, temporarily.

The U.S.-Quebec border near the Lacolle crossing features many heavily wooded areas. (Jaela Bernstien/CBC)

While working a night shift earlier this month, Mamadou said a friend called, telling him that immigration officials had turned up at his Bronx apartment.

"I knew that one day it was going to happen to me," he said, believing they were there to deport him.

Mamadou is convinced he faces certain death if forced to return to Ivory Coast, given what happened to his father.

"I'm not safe. I'm young. I have the right to live."

After hearing about the visit from immigration officials, Mamadou said, he fled to Philadelphia, where he borrowed money from some friends and took a taxi to Plattsburgh, N.Y.

How Safe Third Country deal works

He acknowledges he did little research before attempting to enter Canada. He was drawn by its reputation as a peaceful country, along with his own conviction that he was no longer safe in the U.S.

Hundreds of asylum seekers in the U.S. have left the country for Canada since Donald Trump's election as president. Trump's administration has taken measures to increase deportations, and refugee advocates south of the border report widespread anxiety among would-be immigrants whose status is uncertain.

Many of the migrants fleeing the U.S. have opted to cross the Canadian border illegally, especially near Emerson, Man., and Hemmingford, Que. Doing so allows them to exploit a loophole in the Safe Third Country Agreement.

Razak Iyal, 35, and Seidu Mohammed, 24: The two Ghanaian refugees who lost several fingers to frostbite when crossed into Manitoba on Christmas Eve. (CBC)

The agreement prevents most migrants from claiming asylum in Canada if they are coming from so-called "safe" countries, most notably the U.S.

But the agreement only applies at legal border crossings, giving those who cross elsewhere, illegally, a chance to remain eligible to seek refugee status.

Immigration lawyers across the country have argued the Safe Third Country Agreement provides an incentive to asylum seekers to attempt an illegal crossing, even if it can be dangerous.

They point to two Ghanaian refugees who lost most of their fingers to frostbite when they made the seven-hour trek from North Dakota to Manitoba on Christmas Eve.

Dozens of lawyers have signed a petition calling on the federal government to withdraw from the agreement.

But Immigration Minister Ahmed Hussen has said he isn't convinced the agreement is the reason so many asylum seekers are taking the risk of crossing the border into Canada illegally.

Only chance for Canadian asylum gone

Under Canadian immigration law, someone can only apply once for asylum status.

By applying at the Lacolle border crossing, where his application was doomed at the outset because of the Safe Third Country Agreement, Mamadou used up his chance.

He is now facing deportation to Ivory Coast. He will appear before a hearing on Thursday to determine whether he remains in detention pending his removal.

After being turned away at the Canadian border the first time, Mamadou said he waited near the U.S. entry point until darkness fell. He then set off into the woods, but was soon lost.

He forged ahead as tree branches whacked him in the face. He climbed a hill at one point but lost his footing and slid all the way down. That was just the beginning.

Mamadou attempted to cross a body of water, believing it was solidly frozen.

"When I stepped on the ice, then everything opened up," he said.

Ivory Coast was engulfed in civil war between 2002 and 2007, pitting the Christian south against the Muslim north. The post-conflict transition has been unsteady at times. (Rebecca Blackwell/Associated Press)

But he pressed on, only to come upon another body of water, bigger this time. Seeing no other way around, he waded in.

"All my clothes stuck to my skin. In 10 minutes, they became ice," he recalled.

When he regained consciousness in the hospital, he was told doctors had to cut the clothes from his body. He's kept the pieces.

While in hospital he was handcuffed to his bed, and then escorted to the Laval detention centre on Friday.

In pain, he was unable to put his socks back on after showing a CBC journalist his weather-beaten feet.

Sleeping remains difficult, he said, because of the nightmares.

"I'm dreaming about the forest," he said. "I'm screaming, and no one is around for my rescue."