Law enforcement officials can rifle through your private Facebook account without your knowledge — and there’s nothing the social media giant can do about it.

That was the ruling of New York’s highest court Tuesday when Facebook lost its years-long legal battle to block search warrants from the Manhattan District Attorney’s Office seeking access to hundreds of user accounts.

The 5-1 majority on the Court of Appeals reaffirmed two lower-court rulings that said only users themselves, not Facebook, have the right to challenge warrants in criminal proceedings.

But in this case, the warrants are subject to a gag order, so Facebook was not allowed to warn users about the disclosure.

Facebook has not given up, saying that the case addresses unresolved questions about online privacy, hinting that the company might seek to have the case heard by the US Supreme Court.

“We are continuing to evaluate our options because we believe strongly in the issues underlying this case,” a Facebook spokesman said.

Experts predict that Facebook founder Mark Zuckerberg will have his lawyers ask for a hearing before the nation’s top court.

“These issues are important for social media platforms and their users, so I would expect that a certiorari petition by Facebook would be given serious consideration” by the Supreme Court, said legal expert Andrew B. Lustigman.

The lone dissenting judge in Tuesday’s decision, Rowan Wilson, chastised his colleagues for punting on the issue.

“Let us decide this thing on the merits,” he wrote.

“Our state constitution, unlike its federal counterpart, includes explicit protections against unreasonable searches and seizures of electronic communications,” he wrote in the dissent.

Manhattan DA Cyrus Vance Jr. sought the search warrants in 2013 for the accounts of 381 people in connection with a disability-benefits fraud case against NYPD and FDNY retirees.

More than 100 people have been convicted in the scam so far.

They claimed they were too sick to work in order to get the benefits — then posted photos of themselves on social media platforms like Facebook in such activities as jet-skiing and sport fishing.

Facebook first challenged the sealed warrants in 2015. Earlier this year, the company argued before the Court of Appeals that the DA’s demand for information from hundreds of private accounts was unprecedented.

“The DA’s ultimate position in this case is chilling. Under his view, he could seize the entire digital lives of everyone in New York City,” Facebook attorney Thomas Dupree Jr. said in February.

While the Court of Appeals acknowledged that the case “undoubtedly implicates novel and important substantive issues regarding the constitutional rights of privacy and freedom from unreasonable search and seizure,” the majority found that they were constrained by the current law that bars appeals by third parties.

The court said the only remedy for Facebook users is to sue for invasion of privacy after the fact.

A spokesman for Vance said, “We are pleased with the outcome and thank the court.”