OTTAWA - An alleged al Qaeda sleeper agent emphatically denied running a safe house for Afghan fighters in Pakistan as he recounted his flight from his native Algeria to eventually seek refugee status in Canada.

Mohamed Harkat, 41, took the stand Monday at a Federal Court hearing examining the validity of a rarely used security certificate against him.

The former Ottawa gas attendant and pizza delivery man has been in legal limbo -- charged with no crime but under threat of deportation -- for seven years on secret evidence that is largely barred from Harkat or the public.

Two of the principal links to terrorist-support networks that have been alleged against Harkat involve a Peshawar safe house and claims of ties to Ahmed Said Khadr, a known associate of Osama bin Laden and the father of imprisoned child-soldier Omar Khadr.

Harkat flatly denied both.

"Your honour, I never worked for Khadr or went in his office" in Peshawar, Harkat told Justice Simon Noel, adding he "never met" Khadr at the time.

As for a Peshawar safe house, it "never happened," said Harkat.

Harkat's halting narrative, drawn out by his lawyer Matt Webber, was of a somewhat naive young university student who fled his homeland in 1990 after lending a vacant family home to an opposition political party that ran afoul of Algerian authorities.

"For me it was like my nightmare started," Harkat testified.

With US$250 in his pocket -- enough to live on for a year in Algeria -- and a vague plan to continue his electronic engineering studies or to work, Harkat travelled to Saudi Arabia on an easily obtainable but temporary visa for pilgrims to Mecca.

There he very quickly learned he could neither study, work nor live for long on his meagre savings, Harkat testified. Within days, a student contact had put him in touch with the Muslim World League in Jeddah and he was appealing to the government-backed agency for help finding work.

"In a couple of steps, I'm going to find myself homeless," said Harkat.

He was offered a job by the Muslim World League in Pakistan, including transportation and a visa -- an offer that Harkat said he never considered declining, "a huge thing, basically life or death."

For the next four years, Harkat says, he ran a Muslim World League aid warehouse in a huge Afghan refugee enclave near Peshawar, living in the warehouse itself.

Authorities checked his documentation on a daily basis, he said, his work visas were regularly renewed by police and he drove a vehicle identified as belonging to the Muslim World League.

By 1994 Pakistan authorities had begun pushing out the 100,000-strong Afghan refugee community, along with foreign Arab workers. Harkat testified he couldn't get his work visa renewed, was out of work with the Muslim World League by June and had no hopes of finding legal employment.

He lived in a vacant former school house in the Afghan enclave until September 1995, when he says he used US$10,000 in savings to buy a fake Saudi passport and fly to Toronto, where he promptly offered himself up to authorities as a refugee and declared his fake travel document.

It wasn't until December 2002 that Harkat was arrested in Canada under a national security certificate.