After months of on and off negotiations, the federal government has reached a settlement with three Canadian men as compensation for the role Canadian officials played in their torture in Syria and Egypt.

Public Safety Minister Ralph Goodale and Foreign Affairs Minister Chrystia Freeland issued a statement Friday saying that with the settlement and an apology from government, the civil case involving Abdullah Almalki, Ahmad Abou-Elmaati and Muayyed Nureddin was now closed.

"On behalf of the government of Canada, we wish to apologize to Mr. Almalki, Mr. Abou-Elmaati and Mr. Nureddin, and their families, for any role Canadian officials may have played in relation to their detention and mistreatment abroad and any resulting harm," the statement said.

The statement does not provide any details about the nature of the settlements reached, financial or otherwise.

I was shocked that my country, which was supposed to work for my safety, let me end up in the torture chamber. - Muayyed Nureddin

The settlement averts a long and potentially embarrassing trial for the government that was set to begin late last month.

It comes 15 years and two federal inquiries after the detention and torture of the three men.

"Our clients are gratified to have received an apology from the highest level of the Canadian government," Phil Tunley, a lawyer representing the three men, told CBC News in an emailed statement. "They and their families are pleased that their long legal ordeal is over."

Ten years ago, they each filed $100-million lawsuits against the government but temporarily halted their legal proceedings to allow former Supreme Court justice Frank Iacobucci to conduct an internal inquiry. In his 2008 report, Iacobucci concluded that Canadian officials were indirectly responsible for their torture.

In 2009, the House of Commons called on the government to provide compensation and a formal apology to Almalki, Elmaati and Nureddin and to do everything necessary to correct misinformation about them that may exist in records administered by national security agencies in Canada or abroad.

The three men have been waiting until now.

Official documents

Lawyers representing Almalki, Elmaati and Nureddin fought and eventually won a lengthy court battle against the RCMP and CSIS to gain access to thousands of heavily redacted files, amounting to hundreds of thousands of pages.

They consist of internal memos, briefing notes from field agents to their superiors, interagency communications, emails, reports and even a memo that shows at least one senior RCMP officer might have had serious doubts about evidence suggesting Almalki was engaged in nefarious activity.

(Natalie Holdway/CBC)

CBC News obtained exclusive access to some 18,000 pages, which showed that Canadian law enforcement officials not only knew three Canadians were being tortured in Syrian jails in a post-9/11 crackdown but also co-operated with Syrian officials in their interrogations.

The files also show that a Canadian ambassador helped to deliver questions the RCMP and CSIS wanted put to the Canadians imprisoned in Syria, a country with a dismal human rights record.

The revelations were featured in The Torture Files, a 2016 joint investigation by The National and The Fifth Estate.

Revelations arose from Maher Arar case

The circumstances surrounding the detention and torture of ​Almalki, Elmaati and Nureddin were substantially similar to those of Syrian-Canadian Maher Arar.

A 2006 inquiry led by Justice Dennis O'Connor found that Canadian officials played a role in Arar's torture, and he received an apology and $10.5 million from the federal government. O'Connor also recommended a review of Almalki, Elmaati and Nureddin's cases.

Following an internal inquiry, Frank Iacobucci released his report on Oct. 21, 2008, which found the actions of Canadian officials contributed indirectly to the torture of Almalki, Elmaati and Nureddin in Syria and Egypt. (Adrian Wyld/Canadian Press)

Almalki, a Syrian-born graduate in electrical engineering from Ottawa's Carleton University with a successful electronics export business, was arrested in May 2002 upon his arrival in Damascus to visit family. He was held in custody for 22 months.

He said he was beaten and tortured for seven hours on his first day of detention. His interrogators asked him whether he sold equipment to the Taliban or al-Qaeda. They wanted Almalki to tell them what he was planning in Canada and demanded he confess to being Osama bin Laden's "right-hand man."

Almalki said he was lashed hundreds of times on the soles of his feet, his legs, genitals and other parts of his body. The beatings were so severe, his legs were soaked in his own blood and he experienced paralysis from his waist down.

(Natalie Holdway/CBC)

Almalki blames the Canadian government for his ordeal

"They caused the torture to happen, they caused the detention to happen," he told CBC's The Fifth Estate in June 2016. "They caused huge losses in my business. My brothers, their lives got destroyed. My kids, their lives got destroyed."

'They have betrayed me'

Elmaati went to Damascus to get married in the fall of 2001. He was handcuffed and hooded at the airport and taken to a Syrian prison and tortured. Then he was put on a private jet and sent to Egypt, where he was tortured further. He was released in January 2004.

"I believe that my government have mistreated me," Elmaati told The Fifth Estate last summer. "They have betrayed me, betrayed my trust. And they did not help me in a time of need."

Nureddin, a principal at an Islamic school in Toronto, was detained by Syrian officials in December 2003 as he crossed the border from Iraq.

(Natalie Holdway/CBC)

He said he had no doubt that the questions he was being asked in Syria came from CSIS and the RCMP.

"I was shocked that my country, which was supposed to work for my safety, let me end up in the torture chamber," he said.

Nureddin was held for 34 days in a Syrian dungeon before he was released and allowed to return to Canada.

"My reputation has been damaged," he told The Fifth Estate last year. "So basically I am living in a limbo. I'm not above the ground nor am I under the grave."