History’s record-breaking “Hatfields & McCoys” took so long to get made that Burt Lancaster — who died in 1994 — was once set to star in the role Kevin Costner plays.

But executive producer Leslie Greif never gave up during his decades-long slog to get his labor of love on the air.

“It took me 30 years of knocking on every door,” says Greif, the CEO and founder of Thinkfactory Media. “They’d say, ‘We love you, but don’t mention ‘Hatfields’ again.’ ”

Greif’s stubborness — and History’s savvy in snapping up the miniseries — has paid big dividends for both parties.

The three-part “Hatfields & McCoys” — which tells the violent story of the feuding Kentucky/West Virginia families — premiered to a record 13.9 million viewers Monday night with stars Kevin Costner, Mare Winningham, Bill Paxton and Powers Boothe.

It followed that with a whopping 13.1 million viewers Tuesday night. (The miniseries wrapped last night.)

And, without gloating, Greif — who co-created and produced the Chuck Norris series “Walker, Texas Ranger” — doesn’t hesitate when asked which cable networks passed on his now-epic project.

“You can mention them all, because they all passed: HBO, Showtime, Starz, TNT, TBS, USA, FX,” he says. “I had this thing set up four different times and pitched it to every [broadcast] network . . . and every new regime over 30 years.

“All I heard was, ‘No one wants Westerns.’ ‘Miniseries are over.’ ‘There’s no financial model.’ ‘It will never sell overseas.’ ‘It skews too old and too male.’ Meantime, we’re killing with adults 18 to 49 and with women viewers.

“I started pitching this when I was young and skinny and miniseries like ‘Roots,’ ‘Shogun’ and ‘The Thorn Birds’ were a staple of TV,” he says. “It’s fun to be validated in my belief that this is a timeless tale.”

“I did know that the project had a long and torturous history,” says Nacy Dubuc, the head of the History channel who bought the idea last year. “But I could feel Leslie’s passion for it.

“It’s not a story of good and evil, which viewers tend to like,” she says, suggesting that may have been the reason other networks passed.

“But every network has a different business agenda at a different time,” she said.

“I just had a tingle, a gut instinct when he talked about it.”