In 1957, Oliver Hardy’s heart finally gave out, and he slipped away, dead at the age of 65.

The rotund comedian had been one-half of arguably the greatest comedy duo of the 20th century. His longtime partner, Stan Laurel, was grief-stricken beyond words.

“What’s there to say?” Laurel said in a terse statement at the time. “He was like a brother. That’s the end of the history of Laurel and Hardy.”

Despite being in slightly better health, Laurel never worked again after his partner’s death. He got numerous offers from Jerry Lewis and other top names, but he turned them all down.

Instead, he shut himself away in his modest Malibu apartment until his death in 1965 at 74, and there, he spent much of his time penning comedy love letters of sorts — sketches written for him and his late partner that he knew would never be performed.

It’s hard to imagine two men having a stronger bond than Laurel and Hardy. Their seemingly effortless navigation of complicated slapstick routines and crackling on-screen rapport suggest two people who were beyond best friends.

Except they weren’t.

Despite the chumminess on display in their hundreds of movies, for much of their career together, Laurel and Hardy weren’t particularly close. Shockingly, it was only toward the end of their lives that they became intimate friends.

And it is this thawing that is chronicled in “Stan & Ollie,” a biopic opening Friday.

Steve Coogan fills Laurel’s bowler hat, and John C. Reilly, under a fat suit and facial prosthetics, steps into Hardy’s shoes.

The story picks up in the early 1950s. The comedy duo is washed up, more than a decade past its prime. In search of a paycheck, they agree to a grueling stage tour of England, in which they will sing, dance and perform their classic bits.

‘I think like a lot of things, you tend to appreciate something more when it’s taken away from you.’

The tour, while below the standards of the Hollywood glamour to which they were once accustomed, becomes an emotional career swan song and forges a new bond between the aging performers.

“I think like a lot of things, you tend to appreciate something more when it’s taken away from you,” “Stan & Ollie” director Jon Baird told The Post. “I think they learned to appreciate what they had on-screen, off-screen. That bonded them a lot more.”

The comedians came together almost by accident.

Laurel was born in England in 1890, the son of a theater owner. He was a mischievous child prone to getting himself into comedic situations. He once fell into a barrel of fish guts while wearing his best suit. Another time, he mistook a glass of gin for water and went cockeyed.

“Think this was the forerunner of my film character!” he later wrote in a letter.

At 17, he joined a famed British comedy troupe and worked as understudy to Charlie Chaplin, with Stan later owing much to “Charlie’s encouragement,” Laurel’s father said in 1932. In 1910, the troupe launched a tour of America, and Laurel remained to make a go of it in Hollywood.

Hardy was born in Georgia in 1892. His mother ran a hotel, and as a child, he loved watching people in the lobby and trying to figure out their characters.

He was always a big boy, weighing 173 pounds when he was 13. As a teen with little more than peach fuzz, he went to the barber for a shave and afterward, the barber said condescendingly, “There you go, baby. You’re clean.” The nickname “Babe” stuck.

By the 1920s, the two men found themselves working for producer Hal Roach.

Roach, recognizing that Laurel played best when he had a foil, decided to pair the 5-foot-9 Laurel with the 6-foot-1, nearly 300-pound Hardy. The magic was almost instantaneous. “There was an affinity between them,” Roach later said. “One guy sort of fit the other.”

“This partnership was one of the most miraculous partnerships in human history,” Reilly said at a 92nd Street Y screening of the film earlier this month.

When the first true Laurel and Hardy picture hit theaters in 1927, Stan was already 37 and Oliver 35. The duo would go on to make more than 100 shorts and features together over their career and become the toast of Hollywood.

One of their films, a 1929 silent picture called “Big Business,” finds the dimwitted Stan and the increasingly aggravated Ollie peddling Christmas trees door-to-door. The short is a trademark mix of physical comedy — Stan keeps getting the tree caught in a customer’s door — and witty writing. When Stan asks a woman if her husband might want a tree, the woman replies, “I have no husband.” Stan pauses, then asks, “If you had a husband, would he buy one?”

“In their movies, Laurel and Hardy are so close and such perfect friends,” “Stan & Ollie” writer Jeff Pope told The Post. “But in real life, what I discovered was, they weren’t as close as in their films.”

The secret to their longevity could be attributed to the fact that they were not particularly chummy off-screen.

“I think our success is due to the fact that we never mixed socially,” Laurel said in a 1959 interview. “There was never any jealousy between the team, in that [Hardy] left everything to me.

“He was very happy to know he didn’t have to be worried or have any responsibility at all. He didn’t accept any responsibility.”

True enough, Laurel was a workaholic who wrote much of the material and sometimes slept in the editing room. He rarely took vacations, and as soon as he finished a movie, he’d start another.

Hardy was a bon vivant who golfed nearly every day, hitting the links with Babe Ruth, W.C. Fields and other celebrities. He was also a prolific gambler.

“Babe wasn’t serious,” Laurel said in 1959. “He loved to play. He didn’t hold much interest in the production of the pictures. I’d never see him between pictures. We’d call up and say, ‘When do we start?’ ”

Laurel loved fishing and owned a boat, but his partner rarely joined him on the water. “We can’t see the boat when Ollie gets on,” Laurel once cracked.

The one thing they did have in common was their romantic troubles. Laurel was married five times, twice to the same woman. Hardy didn’t fare much better. He got hitched three times, and had one ex still chasing him even on his death bed.

The limited social overlap between Laurel and Hardy kept them from fighting. Roach claimed he never heard them argue while working, or otherwise.

“Why should we argue?” Hardy said in a 1949 interview. “We both do different things professionally. What I do, he can’t do, and vice versa.”

Stan was a much better writer, gag man and production expert, while Ollie was especially valued for his unique on-screen presence, “the elephant on tippy-toe, who always got stuck in upper berths, daintily fingered his necktie, twitched his ridiculously tiny mustache, lost his too-small derby,” as the Los Angeles Times wrote in 1957.

The disparity in responsibilities seems to be reflected in their paychecks. In 1937, Hardy reportedly made $85,316 from the studio, while Laurel took home $156,266, but even the huge gap did not seem to cause friction between the partners.

“Stan & Ollie” suggests Laurel was bitter about “Zenobia,” a 1939 flick Hardy made without his partner when Laurel was briefly without a studio contract. (Laurel probably still got paid for Hardy’s work. In 1935, the two had formed a joint corporation into which their earnings flowed.)

By 1945, fed up with the poor stories and untalented co-stars that were being foisted on them, the pair had quit the film ­business.

Laurel and Hardy began touring Europe, where they remained popular. They stayed in modest hotels and performed a grueling schedule of 13 shows a week.

The travel took its toll, however. Hardy suffered a mild heart attack in 1954. The hardship brought them closer together.

“When you read Stan’s letters, you can see he’s full of concern for Hardy’s health,” Pope said. “You can see that they are looking out for each other and really cared about each other.”

But it was too late. Laurel suffered a mild stroke in 1955 and Hardy a major one the next year, from which he never recovered. He died on Aug. 7, 1957.

“I miss him more than anyone will ever know & feel quite lost, but I will forever cherish the wonderful memories I have of him,” Laurel wrote in a 1957 letter, eight years before his own death.

“Stan was so heartbroken when Ollie died,” Baird said. “His life partner was no longer there and Stan couldn’t let him go. A part of him died when Ollie died.”

(One of those gags Laurel wrote after Hardy died finds its way into “Stan & Ollie” and involves crying into a plant, causing it to grow wildly.)

The two left a lasting mark on comedy and have become such well-known characters, simply their silhouettes are recognizable.

“People keep asking, ‘When did you first become aware of Laurel and Hardy?’ ” Reilly said at the Y. “I became aware of them when I became aware. I mean, when did you become aware of salt and pepper?

“They’re always there, will always be there. They have an eternal quality.”