NBC entertainment chief Bob Greenblatt forgot the first rule of network TV: Do no harm.

After finishing the fall season on top of the ratings heap for the first time in nearly a decade, NBC is suddenly mired in last place again — and close to earning the dubious distinction of having the worst midseason schedule in the history of broadcast television.

Greenblatt, who is in only his second season as the network’s entertainment chairman, is feeling the harsh glare of the spotlight just as parent Comcast gets ready to report earnings tomorrow. Comcast owns 51 percent of NBCUniversal.

Thanks to the strength of Sunday night football and “The Voice,” NBC had a shockingly good fourth quarter, attracting an average of 8.25 million viewers in primetime and winning its first sweeps period in nine years.

What a difference a few weeks makes.

Without those shows to start the new year, NBC lost nearly half its younger viewers ages 18 to 49, the audience advertisers care about most. And total viewers hit a low of just 4.9 million at the end of last week.

“The network also got older,” said Horizon Media research chief Brad Adgate. “They’ve gone from an average age of 49 years to 51.5 years old. All the numbers are headed in the wrong direction.”

Part of the once proud Peacock’s problem is a disastrous slate of midseason replacements that included “Do No Harm,” which is likely to go down as one the biggest flops in the network’s history.

The Dr. Jekyll and Mr. Hyde medical drama drew an abysmal 3.1 million total viewers in its debut and was canceled after just two episodes.

Nielsen is set to release another week of humbling mid-season ratings today, adding to the pressure on Greenblatt to junk more shows.

Industry chatter is swirling that Greenblatt will have to cancel his big-budget Broadway musical baby “Smash” after it recorded 4.5 million viewers, down more than 60 percent compared with last year.

Stemming NBC’s slide is getting even tougher with these factors looming:

* Lead actress Christina Applegate is not returning to “Up All Night.”

* The hit comedy “30 Rock” is over, while the finale of “The Office” is May 16.

* “Smash,” “1600 Penn,” “Deception,” “Go On” and “The New Normal” are all struggling.

Just a few weeks ago at a TV critics tour, Greenblatt was feeling cocky and touting NBC’s success.

“I can guarantee you, we don’t have our heads up our asses,” he said in response to a comment by a rival entertainment chief, Fox’s Kevin Reilly, about the TV industry’s misguided focus on live ratings in the age of the DVR.

(News Corp. owns Fox and The Post.)

“I’m surprised at the cockiness,” said ratings watcher Bill Gorman of TVbythenumbers.com. “You could have looked at fall and known these shows might not do so well after you remove the hits. It’s OK for CBS to be cocky — not NBC.”