Will Ferrell has backed out of a comedy about Ronald Reagan’s struggle with Alzheimer’s disease amid outrage from the former president’s family.

The 48-year-old comic had seen the script for “Reagan” and considered starring and producing in the movie — but had a change of heart, a rep for Ferrell told Page Six exclusively Friday.

“The ‘Reagan’ script is one of a number of scripts that had been submitted to Will Ferrell which he had considered. While it is by no means an ‘Alzheimer’s comedy’ as has been suggested, Mr. Ferrell is not pursuing this project,” the rep said.

The rep wouldn’t say whether the decision was a direct result of the outcry from Reagan’s daughter Patti Davis, who on Thursday called the movie “cruel” and Farrell “heartless.”

The flick offers an “alternate take” on history and is set at the beginning of Reagan’s second term —when he’s struck by dementia, according to the Hollywood Reporter, which scored a copy of the script.

Comedic bits center on the idea that president had no clue where he was or what he was doing through the term, the showbiz news site reported.

In one scene, a low-level aid is tasked with convincing the commander-in-chief that he is an actor playing the president in a movie.

In another, there’s a mix-up over a wardrobe assistant named Libby and the country Libya. “I want Libby gone. No more Libby!” Reagan proclaims — leading to the bombing of Libya.

The script was praised in Hollywood circles and was popular enough to draw actors such as James Brolin, John Cho and Lena Dunham to a reading last March, according to the Hollywood Reporter.

But it infuriated Reagan’s family, who called it stunningly insensitive.

“There’s nothing funny about Alzheimer’s. It is terrifying for the families of those who suffer from it. They live with the fear [of] what will change next, they have to live with this terror and grief every day. This movie is cruel, not just to my father, but to the millions of people who have the disease, and the millions more who care for them and watch them suffer every day,” Davis told Page Six Thursday.

On Friday, she cheered Ferrell’s move to ditch the project. “I am so relieved that Will has decided against this film. I can’t imagine that anybody else would sign onto it.”

“I’ve been deluged with letters and personal stories from people who are caring for someone with Alzheimer’s, and those who have just been diagnosed themselves.It really showed how widespread this disease is and how it just devastates families. It is beyond the pale that anyone would make it a comedy about it,” she added.

Her brother, Michael Reagan, echoed her praise. “Thank you for taking the right path,” he wrote on Twitter.

The Alzheimer’s Foundation of America is pleased Ferrell backed out of the project, it said Friday.

“While we have not seen the movie or the script, we can say with confidence that Alzheimer’s disease is not a laughing matter. To the 5 million Americans living with the disease and the family members who are caring for them, Alzheimer’s disease is a brutal thief — one that breaks in, robs them of memories and destroys lives. We are grateful to Mr. Ferrell for choosing not to pursue this film,” said Charles Fuschillo, Jr., president of the group.

Earlier in the week, Davis penned an open letter to Ferrell slamming him for taking on the role. “Perhaps if you knew more, you would not find the subject humorous. Alzheimer’s … steals what is most precious to a human being — memories, connections, the familiar landmarks of a lifetime … I watched as fear invaded my father’s eyes — this man who was never afraid of anything. I heard his voice tremble as he stood in the living room and said, ‘I don’t know where I am,’” it read.

Michael Reagan also tweeted, “#Alzheimers is not a comedy to the 5 million people who are suffering with the disease, it first robs you of your mind and then it kills you.”

And former Reagan staffer James Rosebush told “Fox & Friends” that Reagan did not suffer from Alzheimer’s in his second term. The movie is “an egregious attempt to rewrite presidential history, which to paraphrase Ronald Reagan, ‘will fall on the ash heap of history,’” he said.

He added, “The timing of this is especially spurious as it falls only weeks after [Nancy Reagan’s] passing, which had millions of people mourning her and also attributing her with the grace that she delivered in taking care of him in his last ten years.”

Ronald Reagan died at age 93 in 2004.