The year is 1947. A young Portland banker, Andy Dufresne, is convicted of the murder of Linda Dufresne and Glenn Quintin—his wife and her lover, respectively. Andy is adamant in defending his innocence, but the evidence is overwhelming and he is sentenced to two life sentences in Shawshank Prison. In prison, he strikes up a friendship with a fellow inmate, Red, who has been in Shawshank for 20 years. Red is known as the “man who knows how to get things” and can get almost anything a prisoner could want from the outside world. Andy approaches Red after a month of incarceration requesting a rock hammer in order to pick up his old hobby of rock collecting and shaping.
Shawshank is a cruel and unforgiving environment, with merciless guards, violent outbursts, and frequent instances of sexual assault. Early on Andy becomes the target of persistent rape from a gang called the “The Sisters” and their leader, Bogs. As a way of avoiding this abuse, Andy takes up a week-long job tarring the roof of a nearby factory. While working, he hears the captain of the guards, Byron Hadley, complaining about an exorbitant tax on his inheritance, and Andy sees an opportunity. As a former banker, Andy offers to help Hadley avoid taxation and earns some protection from the bullyish captain.
When Bogs and the Sisters next attack Andy, they beat him up so bad that he is put in the infirmary, but Hadley, newly ingratiated to the former banker, avenges his attack by beating Bogs to a pulp, to such an extent that Bogs gets transferred to a hospital. When Andy returns from the infirmary, he requests a poster of Rita Hayworth from Red, which Red dutifully procures, and which Andy soon hangs on his wall.
As word of Andy's financial expertise becomes more widely known, the warden, Norton, offers Andy a position working in the prison library, where he can better help guards (and Norton) with their financial concerns. There Andy takes an interest in improving the library and helping to educate his fellow inmates, writing to the Senate everyday requesting more books, until they finally cave and meet his demands. At some point, an older inmate, the gentle Brooks, is released from prison into the real world. While it seems as though freedom is all he can ever have wanted, the real world does not agree with the older man, who finds himself in a halfway house after 50 years of imprisonment, and hangs himself in his room.
After Norton institutes a program through which the prisoners can begin working on infrastructure outside the prison walls, he begins accepting bribes from local businesses who fear that prison labor will take away opportunities for their business. Andy hides the money away in a bank account under a fake name, helping the warden launder money for many years.
In 1964, Shawshank welcomes a new inmate, a likable man named Tommy Williams, who becomes a friend of Red and Andy. Andy helps Tommy learn to read and get a diploma, and it eventually comes to light that Tommy knows the person who actually killed Andy’s wife and her lover. Seeing a way to freedom, Andy informs the warden of the evidence, hoping for a second trial, but the warden needs to protect his investment and has Tommy killed and Andy put in solitary confinement for 2 months.
When Andy finally gets out of confinement, he tells Red about his dreams of freedom, to live in Zihuatanejo, a Mexican coastal town. Red says it would never happen, but Andy maintains hope and tells Red that if he ever gets out of Shawshank he should go to a place in Buxton to retrieve a package buried under an oak tree.
The next day, Andy’s doesn’t come out for roll call, having escaped through a hole he has been digging with the rock hammer for many years. He poses as the fake person in whose name all of Norton's money has been deposited, takes the money, and flees to Mexico. In the process, he also tips the police off to Norton's shady business dealings. When the authorities go to arrest the warden, he shoots himself.
After 40 years, Red finally makes parole, and visits the place in Buxton that Andy told him about. He digs up a box full of money and a letter from Andy telling him to come to Zihuatanejo. He does and the two friends reunite.