Mayor Bill de Blasio ordered tall office buildings across the city to crank their thermostats up to 78 degrees beginning Friday as a much-feared heat wave approaches this weekend — and officials search for ways to slash power consumption.

The emergency declaration issued Thursday night applies to all office buildings that are taller than 100 feet and lasts through Sunday evening, when the predicted record-shattering heat is finally expected to break.

It includes carve-outs for residential apartments, commercial spaces — like shops and movie theaters — and temperature-sensitive equipment in the buildings.

“We are about to enter a heat emergency, and must do all we can to keep New Yorkers safe,” said Mayor de Blasio. “The City government is limiting its energy use to reduce strain on the electrical grid, and now private office buildings will also have to do their part.”

The thermostat dictate came a day after a Post reporter asked de Blasio if he had the authority to issue such an order with the approaching near-triple-digit heat — and Hizzoner said he didn’t know.

“I will always be careful since my lawyers are not present about exactly whether we can order or whether it’s encouraged or what rules we can use. We’ll come back to you. It’s a great question,” he said Wednesday. “This is uncharted territory for me because this is the first time we’ve had this level of heat in my administration.”

Officials have publicly worried about embattled utility Con Edison’s ability to keep the lights on with temperatures predicted to hit 98 degrees on Saturday and Sunday.

Rampant humidity will make it feel even hotter with the heat index climbing into the low 100s, weather conditions health experts describe as potentially dangerous.