Bestselling writer Ira Levin, whose novels such as horror classic “Rosemary’s Baby” and the Nazi thriller “The Boys From Brazil” provided meaty movie roles for Mia Farrow and Laurence Olivier, died Monday of a heart attack in Manhattan. He was 78.

Long before authors like Stephen King routinely had their books turned into movies, Levin’s novels moved vividly to the bigscreen. Besides “Rosemary’s Baby” with Farrow and “The Boys From Brazil” with Olivier, Levin’s novels “The Stepford Wives,” “Sliver” and “A Kiss Before Dying” all were made into feature films.

His long-running 1978 play “Deathtrap” was also made into a Sidney Lumet-directed film, starring Michael Caine and Christopher Reeve.

Levin’s page-turning books were once compared by Newsweek writer Peter S. Frescott to a bag of popcorn: “Utterly without nutritive value and probably fattening, yet there’s no way to stop once you’ve started.”

Born in the Bronx, N.Y., Levin’s father was hopeful his son would follow him into the family toy business. But by age 15, Levin determined that he wanted a career in writing; in his senior year of college, Levin won the $200 second-place prize in an NBC-sponsored screenplay-writing competition and launched his career.

Levin worked as a television writer before finishing his first novel, “A Kiss Before Dying,” a murder mystery that was an instant success. His debut won the Edgar Allan Poe Award as the best first novel of 1953, and it was twice turned into a movie — first in 1956 and again in 1991.

It wasn’t until 14 years after his first book that Levin completed his second novel, “Rosemary’s Baby,” the creepy tale of a New York couple in the clutch of Satanists who want the young wife to bear Satan’s child.

“The Stepford Wives” was Levin’s satirical tale of a suburban town where the spouses were converted into subservient robots, while “The Boys From Brazil” detailed a South American underground where the infamous Nazi doctor Joseph Mengele tried to clone Adolf Hitler.

In 1991, Levin wrote a thriller set in a Manhattan high-rise apartment building: “Sliver,” which became a movie starring Sharon Stone.

Besides “Deathtrap,” Levin also wrote the Broadway adaptation of “No Time for Sergeants.” The 1955 show, which launched the career of actor Andy Griffith, ran for more than 700 performances. He wrote several other less successful plays, including “Drat! That Cat!,” which closed after a week in 1966. He wrote for early TV dramas such as “Alfred Hitchcock Presents” and “General Electric Theater.”

His other novels were dystopian sci-fi tale “This Perfect Day” and his last, “Son of Rosemary,” in 1997.

Levin is survived by three sons and three grandsons.