A US citizen trapped in Turkey's third deepest cave for more than a week has been pulled to safety, rescuers say.
More than 150 people were involved in efforts to save caver Mark Dickey after he developed stomach problems in the Morca Cave on 2 September.
Organisers say it was one of the largest and most complicated underground rescues ever mounted.
The lowest point of the Morca Cave, in a remote part of the south, reaches nearly 1.3km (0.8 miles) below ground.
Mr Dickey was brought out of the cave at 00:37 local time (21:37 GMT), the Turkish Caving Federation announced on social media.
Carl Heitmeyer of the New Jersey Initial Response Team, a group Mr Dickey leads, told BBC News that the caver had been rescued and expressed his thanks to all those involved in the operation.
Mr Dickey said he questioned whether he would survive the ordeal after his condition worsened. He told reporters the thought that he might die "literally went through my head".
"I kept throwing up blood. Then my consciousness started to get harder to hold on to and I reached a point where I said, 'I'm not going to live'," he said.
His parents Debbie and Andy Dickey said the "international caving community" had "made it possible for Mark to leave Morca cave and receive further medical treatment at a hospital facility".
They said their son's rescue was "indescribably relieving" and filled them with "incredible joy".
"Mark is strong and we believe in his strength, but fully knew that he was in dire need of tremendous and immediate support," they said.
Mr Dickey had been co-leading a team to map a new passage in the cave when he began to suffer from gastrointestinal bleeding.
His condition improved after he was given a blood transfusion. He was then strapped to a stretcher and was slowly carried out.
This involved navigating through tight rock tunnels and explosives had to be used at the narrowest points, according to CBS, the BBC's US partner.
A number of rescue workers from several other countries, including Croatia and Hungary, flew to Turkey to assist in the rescue.
Mr Dickey's fiancee, Jessica Van Ord, also helped. She had remained in the cave with him while he was unwell but later climbed out.
On Thursday evening, in a video message from inside the cave, Mr Dickey thanked the people attempting to rescue him.
"I do know that the quick response of the Turkish government to get the medical supplies that I need, in my opinion, saved my life," he said. "I was very close to the edge."
Rescuers said helping to save Mr Dickey had been a "very honourable" experience.
"We are cavers before everything," Ibrahim Olcu, a caver from Istanbul, said.
"A caver does not have a rescuer other than another caver, we saw that a little. To work in the rescue operation for another caver was very honourable, pleasing. I am experiencing this happiness."
Zsofia Zador, a Hungarian anaesthesiologist, said it was her first "big rescue for me as a doctor".
"This is quite a difficult cave because there are some small narrow passages and the shafts are quite muddy so it is not the easiest cave to traverse," she added.
Mr Dickey, who hails from New Jersey, is said to be a hardened caver with over 20 years' experience.
He has been an instructor with the US National Cave Rescue Commission for 10 years, teaching a variety of cave rescue classes. He is also listed as the body's International Exchange Program Co-ordinator on its website.
He had been co-leading the expedition to the Morca Cave since the end of August, according to the Hungarian Cave Rescue Service, who have also been assisting with the operation.