In 1947, a banker named Andrew “Andy” Dufresne (Tim Robbins) is convicted of murdering his wife and her lover, based on strong circumstantial evidence. He is sentenced to two consecutive life sentences at Shawshank State Penitentiary in Maine, run by Warden Samuel Norton (Bob Gunton). Andy is quickly befriended by Ellis Boyd “Red” Redding (Morgan Freeman), a fellow inmate serving a life sentence who has recently failed to gain parole. Andy finds Red has connections on the outside who can acquire contraband for the inmates. He first asks Red for a rock hammer, explaining that he wants to use it to maintain his rock collection hobby, which he uses to fashion a home-made chess set. He later asks Red for a full-size poster of Rita Hayworth for his wall, replacing the poster over the years with ones of Marilyn Monroe and Raquel Welch.

While doing manual labor, Andy overhears Captain of the Guards Byron Hadley (Clancy Brown) complain about having to pay taxes on a forthcoming inheritance. After explaining to Hadley how to circumvent the taxes legally, Andy’s financial advice is soon sought by other guards at Shawshank and nearby prisons. Because of this, Andy is given a space to work on their financial matters alongside elderly inmate Brooks Hatlen (James Whitmore). Hadley delivers a brutal beating to inmate Bogs (Mark Rolston), leader of “The Sisters,” after his gang’s sexual assault puts Andy in the infirmary; Bogs is paralyzed, and the remaining Sisters leave Andy alone. Andy uses his goodwill with the guards to expand the prison library. When one donation to the library provides him with the opera The Marriage of Figaro, he plays it over the public address system for all the inmates to hear, well-aware of the punishment of solitary confinement he will receive for the brief moment of bliss.

Warden Norton eventually creates a scheme to use prison labor for public works, undercutting the cost of skilled labor and receiving kickbacks for it. Norton has Andy launder the money under the false identity of Randall Stevens, in exchange for allowing Andy to keep his private cell and to continue maintaining the library. Meanwhile, Brooks, freed on parole, is unable to adjust to the outside world, and hangs himself; Andy dedicates the expanded library to him.

In 1965, Tommy Williams (Gil Bellows) is incarcerated on robbery charges. He is brought into Andy and Red’s circle of friends, and Andy assists him in getting his GED. Upon learning of the crime of which Andy was convicted, Tommy reveals that one of his fellow inmates at another prison, Elmo Blatch (Bill Bolender), had claimed to have committed a nearly identical murder – this might prove that Andy, who had always maintained his innocence, was indeed not guily. Norton, fearing the end of the flow of money that Andy was looking after for him, and fearing that Andy might tell of his (Norton’s) corruption if released, puts Andy into solitary confinement and has Tommy killed by Hadley, claiming he was an escapee.

Shortly after he returns to his regular cell block, Andy tells Red of his dream of living in Zihuatanejo, a Mexican-Pacific coastal town, and instructs Red, should he ever be freed, to visit a specific hayfield near Buxton to find something Andy had left there. The next day at roll call, Andy’s cell is found empty. Norton, in anger, throws one of Andy’s rocks at the poster of Raquel Welch; to everyone’s astonishment, the rock tears through the poster, revealing a tunnel that Andy had dug with the rock hammer over the last two decades. A flashback shows that Andy, the night before, had switched the ledger book he had kept for Norton with his prison-issue Bible. Taking the ledger, his chess set and one of the warden’s suits, he had made his escape through the tunnel and a narrow sewage drain during a thunderstorm. At the same time that Norton discovered Andy’s escape, Andy used the identity of Randall Stevens to withdraw most of Norton’s money from several banks, then sent evidence of Norton’s corruption to a local newspaper. On the day the story runs, the police converge on the prison; Hadley is arrested while Norton commits suicide.

When Red finally receives parole after serving 40 years, he finds himself living in the same apartment in which Brooks committed suicide, and working at the same grocery store. Red decides to follow Andy’s advice and visits Buxton. In the hayfield specified by Andy, he finds a cache of money and a note left by Andy, reminding him of Zihuatanejo. Red violates his parole and travels to Mexico, where he happily reunites with Andy on the beach.