Police Commissioner Raymond Kelly ordered a major shakeup of the department’s upper ranks yesterday, transferring the veteran commander of the Special Operations Division whose unit led a botched raid that caused the death of a Harlem woman.

Assistant Chief Thomas Purtell, commander of the elite division that includes the Emergency Service Unit, was reassigned to the department’s Housing Bureau, where he will be second in command.

Purtell is switching jobs with Assistant Chief Charles Kammedaner.

The transfer is the second major reassignment since the death of Alberta Spruill during a botched raid on her apartment by the ESU on May 16. A captain from the 25th Precinct was transferred to a Brooklyn command center last week.

Spruill, 57, died of a heart attack after cops, acting on a bad tip about a drug stash, raided her West 143rd Street apartment and set off a stun grenade. The medical examiner this week ruled the death a homicide.

Mayor Bloomberg has apologized for Spruill’s death and has taken responsibility for it. Kelly also has rolled out several procedural changes on how police raids are conducted.

But some elected officials and community leaders are saying that doesn’t go far enough.

“Heads need to roll,” City Councilman Charles Barron (D-Brooklyn) said during a council meeting yesterday. “Somebody should pay for that. I don’t think we should just change police procedures, but somebody needs to be arrested and prosecuted.”

ESU cops say Purtell, a hero during the World Trade Center attack, is being unfairly singled out because of political pressure. Purtell, they say, had no role in the raid that was prompted by information from the local precinct.

“He’s being made a scapegoat to placate the angry crowd,” an angry ESU officer said of Purtell’s transfer. “He did nothing wrong.”

Purtell, 43, led ESU cops during the 9/11 WTC attack and bravely regrouped his battered unit after the towers collapsed.

Fourteen of the 23 NYPD cops who died in the attack were from the ESU.

Before taking over the Special Operations Division, Purtell was commander of Midtown North. He also has commanded the 44th Precinct in The Bronx.

Meanwhile, Manhattan Borough President Virginia Fields yesterday set up a new hot line for New Yorkers to report unnecessary police raids.

“I want to hear from people who have found themselves in similar situations through no fault of their own,” she said.