On October 6, 1970, on holiday in Istanbul, Turkey, American college student Billy Hayes straps 2 kg of hashish blocks to his chest. While attempting to board a plane back to the United States with his girlfriend, Billy is arrested by Turkish police on high alert for fear of terrorist attacks. He is strip-searched, photographed, and questioned.
After a while, a shadowy American – who is never named but is nicknamed "Tex" by Billy, for his thick Texan accent – arrives, takes Billy to a police station, and translates Billy's English for one of the detectives. Billy says that he bought the hashish from a taxicab driver and offers to help the police track him down in exchange for his release. Billy goes with the police to a nearby market and points out the cab driver, but when they go to arrest the cabbie, it becomes apparent that the police have no intention of keeping their end of the deal with Billy. He sees an opportunity and makes a run for it, only to get cornered and recaptured by the mysterious American.
During his first night in holding at a local jail, a freezing-cold Billy sneaks out of his cell and steals a blanket. Later that night, he is rousted from his cell and brutally beaten by chief guard Hamidou for the theft.
A few days later, Billy wakes up in Sağmalcılar Prison, surrounded by fellow Western prisoners Jimmy (an American who is in for stealing two candlesticks from a mosque), Max (an English heroin addict), and Erich (a Swede, also in for drug smuggling), who help him to his feet. Jimmy tells Billy that the prison is a dangerous place for foreigners like them and that no one can be trusted, not even young children.
Billy meets his father, along with a US representative and a Turkish lawyer, to discuss what will happen to him. Billy is sent to trial for his case, during which the angry prosecutor makes a case against him for drug smuggling. The lead judge is sympathetic to Billy and gives him only a four-year sentence for drug possession. Billy and his father are horrified at the outcome, but their Turkish lawyer insists that it is a very good result.
Jimmy tries to encourage Billy to become part of an escape attempt through the prison's tunnels. Believing that he is to be released soon, Billy rebuffs Jimmy, who goes on to attempt an escape himself. Caught, he is brutally beaten. Then, in 1974, Billy finds out, 53 days before he is due for release, that his sentence has been overturned by the Turkish High Court in Ankara after an appeal by the prosecution. The prosecutor originally wished to have him found guilty of smuggling and not the lesser charge of possession. Billy is shocked to find out that he now has to serve 30 years for his crime.
In desperation, Billy goes along with a prison break that Jimmy has masterminded. Along with Jimmy and Max, he tries to escape through the catacombs below the prison, but their plans are revealed to the prison authorities by fellow prisoner Rifki. His stay becomes harsh and brutal: terrifying scenes of physical and mental torture follow one another, and Billy has a breakdown. He brutally beats Rifki, killing him, and shortly thereafter bites out Rifki's tongue. He is sent to the prison's ward for the insane, where he wanders in a daze among the other disturbed and catatonic prisoners.
In 1975, Billy's girlfriend, Susan, comes to see him. Devastated at what has happened to Billy, she tells him that he has to escape or he will die in there. She leaves him a scrapbook with money hidden inside as "a picture of your good friend Mr. Franklin from the bank" in the hope that Billy can use it to help him escape. Her visit moves Billy strongly, and he regains his senses.
Billy says goodbye to Max, telling him not to die and promising to come back for him. He then tries to bribe Hamidou into taking him where there are no guards, but Hamidou takes Billy to another room and physically assaults him. Hamidou prepares to rape Billy and they struggle until suddenly and inadvertently Hamidou is killed after being pushed into the wall, his head impaled upon a coat hook. Here, Billy seizes the opportunity to escape by putting on a guard's uniform and walking out of the front door.
In the epilogue, it is explained that on the night of October 4, 1975, Billy successfully crossed the border to Greece and arrived home three weeks later.