An Australian academic freed by the Taliban in a prisoner swap has spoken of his "long and tortuous ordeal" as a hostage in Afghanistan.
Timothy Weeks said he believed US special forces had tried six times to rescue him and an American captive, Kevin King, who was also released.
Mr Weeks said he did not hate the Taliban, saying some of his guards were "lovely people" he hugged as he left.
"I never, ever gave up hope... I knew I would leave eventually," he said.
Mr Weeks and Mr King, also an academic, were freed this month in exchange for three senior militants held by the Afghan authorities, in a deal aimed at kick-starting peace talks.
The pair had been held for three years after being abducted outside the American University of Afghanistan in Kabul, where they worked as professors.
Mr Weeks, a 50-year-old from Wagga Wagga in New South Wales, was speaking at a press conference after returning to Australia on Thursday night.
He said he believed numerous attempts were made to rescue him and that he was held in several locations, often small windowless cells in both Afghanistan and Pakistan.
"I believe, and I hope this is correct, that they (special forces) came in six times to try to get us, and that a number of times they missed us only by hours," Mr Weeks said.
He recalled one such mission in April, when his guards told him they were under attack by militants of the rival Islamic State (IS) group.
"I believe now that it was the Navy SEALs coming in to get us," Mr Weeks said.
"I believe they were right outside our door. The moment that we got into the tunnels, we were one or two metres underground and there was a huge bang at the front door.
"And our guards went up and there was a lot of machine-gun fire. They pushed me over the top into the tunnels and I fell backwards and rolled and knocked myself unconscious."
He said he had accepted that his guards were soldiers acting under orders and that they "don't get a choice".
"I don't hate them at all," he said. "And some of them I have great respect for, and great love for, almost. Some of them were so compassionate and such lovely, lovely people. And it really led me to think about... how did they end up like this?"
Mr Weeks also recalled his release, saying his ordeal "ended as abruptly as it had begun" as two US Black Hawk helicopters descended from the skies.
"Out of a big dust cloud came six special forces and they walked towards us and one of them stepped towards me and he just put his arm around me and he held me and he said, 'Are you OK?' And then he walked me back to the Black Hawk."
Mr Weeks said that his time as a hostage had had a "profound and unimaginable effect".
But he never gave up hope because "if you give up hope, there is very little left for you".
He said: "At times, I felt as if my death was imminent, and that I would never return to see those that I loved again. But, by the will of God, I am here, I am alive and I am safe - and I am free."