A Long Island political power broker was shot in the face Monday on the sprawling grounds of his Oheka Castle in an attempted assassination.

A masked man fired a bullet into Gary Melius, 69, just as he was getting into his Mercedes-Benz at around 12:30 p.m. in the valet area of the Huntington estate, which he uses as a hotel, catering hall and his family residence, authorities said.

Melius — a kingmaker with deep ties to officials in the Democratic, Republican and Independence parties — crumpled to the ground as the masked gunman hopped in a Jeep Cherokee and his getaway driver sped off.

Melius’ daughter, Kelly, heard a gunshot from inside the castle and rushed out to him.

“Take me to the hospital,” Melius pleaded before his daughter took him to Syosset Hospital. He was transferred to North Shore University Hospital in Manhassett, where an eye surgeon was called in to treat the wound.

Melius was listed in stable condition Monday night.

Former Sen. Alfonse D’Amato — one of Melius’ many political-heavyweight pals — visited him and said the developer had no idea why he had been targeted.

“He didn’t understand why the shooting happened. He said, ‘Why?’ He couldn’t believe it,” D’Amato recalled. “It was an assassination attempt, not a robbery.”

The bullet went through a window of Melius’ car, which redirected the bullet enough to avoid a “clean head shot,” one of his friends said.

“It does not appear to be an accidental shooting at this time,” said Detective Sgt. John O’Sullivan of Suffolk’s Second Squad Detectives.

O’ Sullivan said a relative had called the shooting in to Suffolk Police.

“As best we can determine, he was entering his vehicle [when he was shot],” the detective said.

Cops were searching for the gunman and his driver Monday night, but could find no witnesses.

The Suffolk canine unit, aviation unit and precinct patrol searched the 443-acre grounds for clues.

Police said they were not aware of any recent threats against Melius or Oheka Castle.

D’Amato said he was supposed to meet Melius, his longtime poker partner, for lunch in Roosevelt when Melius called and said he was running 15 minutes late.

“The next thing I know, his daughter called and said he had been shot,” he recalled.

D’Amato said that at the hospital, “Gary had a good sense of humor for a guy who was shot in the head.”

“The Lord has blessed us. We’re lucky to have him. Gary is going to survive,” D’Amato said.

Cops had yet to interview Melius Monday, and the motive for the shooting was unclear.

Melius frequently holds lavish fund-raisers at his estate on Long Island’s Gold Coast.

He and his wife, Pam, have made $870,000 in campaign contributions since the 1990s — including $11,000 to Gov. Cuomo, $25,000 to state Comptroller Tom DiNapoli, both Democrats, and $5,000 to Republican state Senate Majority Leader Dean Skelos.

Last year, Melius was a key figure in the ouster of Nassau County Police Commissioner Thomas Dale.

Melius had told Dale that Democratic ex-Freeport Mayor Andrew Hardwick, a friend, wanted to file a perjury charge against Randy White, a witness in a lawsuit challenging the validity of Hardwick’s petition signatures.

White was never charged with perjury. But Dale ordered White arrested because he had an open misdemeanor warrant, said District Attorney Kathleen Rice.

White was served with a subpoena by Hardwick’s lawyer while in police custody, which Rice called “deeply troubling.”

Nassau County Democratic Chairman Jay Jacobs said Melius should have been investigated for witness tampering, and also said, “All evil in Nassau politics goes through Oheka Castle.”

On Monday, Jacobs said Melius’ shooting was beyond the pale.

“It’s awful. It’s shocking. Anytime someone of his stature in the community is subject to this kind of violence, it deserves condemnation — no matter what side of the aisle you’re from,” he said.

Melius’ political tentacles extend to state Independence Party Chairman Frank McKay , a close friend. The Nassau County chapter is headed by Melius’ former son-in-law, Rick Bellando.

Bellando is also an Oheka employee.

McKay told The Post Monday night: “Gary is one of the toughest men I know. This was a horrible, cowardly act.”

Melius appears to have financial issues. In 2012, he skipped a payment on Oheka Castle’s $27.9 million mortgage, and he worked to refinance the debt on the French-style castle, which was used as a photo prop for the Xanadu estate in the classic 1941 film “Citizen Kane.”

Records show Melius racked up millions of dollars in judgments and liens in the early ’90s.

“There’s no question Gary is a wheeler dealer. He’s a controversial guy. He’s a hard hitter,” said a Long Island politico.

“His friends and allies love him, and there are other people who don’t like him.”

The Oheka estate was built in 1919 as a summer home by investment banker Otto Hermann Kahn. “Oheka” is taken from the first or second letters of each of those three names.

The manor is frequently used for high-end weddings, including recently that of Melius’ 40-year-old daughter, Kelly.

It was also the site of disgraced ex-Rep. Anthony Weiner’s marriage to Huma Abedin in 2010. Former President Bill Clinton officiated. Pop stars Joey Fatone and Kevin Jonas also held their weddings there.

Additional reporting by Reuven Fenton, Priscilla DeGregory and Leonica Valentine