Mayor Rahm Emanuel on Wednesday scored a big victory in the drive to get ahead of a federal civil rights investigation and restore public trust shattered by the police shooting of Laquan McDonald, but the most difficult battles lie ahead.

That much was apparent after the City Council voted 39 to 8 to approve the first two parts of Emanuel’s police accountability overhaul: A Civilian Office of Police Accountability to replace the Independent Police Review Authority and a deputy inspector general for public safety to audit police practices, recommend changes to the police contract and bird-dog the accountability system.

Six of the eight “no” votes were cast by aldermen who are either former cops or whose wards are home to scores of Chicago Police officers who view the new system of police accountability as being stacked against them: Marty Quinn (13th); Matt O’Shea (19th); Mike Zalewski (23rd); Chris Taliaferro (29th), Nick Sposato (38th) and Anthony Napolitano (41st).

That means the mayor’s job of coaxing police officers out of a defensive crouch at least partially responsible for a 50 percent surge in homicides and shootings will be even more difficult.

“In the appearance of the ordinance, it looks like it’s there to be very one-sided against the police. That’s what the impression is. I heard them loud and clear as far as their very vocal opposition to the ordinance,” Zalewski said.

As if police opposition isn’t enough of a hurdle, Emanuel must also find a way to appease restive community leaders furious about his decision to indefinitely postpone the appointment of a civilian oversight board that will choose a permanent COPA chief to replace IPRA chief Sharon Fairley, who will hold down the fort in the interim.

They made their feelings known by chanting “Hold the Vote” and trying to drown out Public Safety Committee Chairman Ariel Reboyras (30th), who opened Council debate Wednesday.

Emanuel stood stoically on the rostrum as the protesters were escorted from the City Council chambers.

While the mayor was addressing aldermen after the vote, a protester who managed to avoid eviction shouted, “Sixteen shots and a cover-up. We’ll never forget,” referring to the mayor’s handling of the Laquan McDonald shooting video.

“That’s true,” Emanuel replied. “Because we’re gonna use that to make the necessary changes. Not run away from ’em. Confront them. Not only to make the changes necessary . . . . I firmly believe the public safety that we seek for our city, this is an important component. . . . We all know release of the Laquan McDonald video started something different.”

After the meeting, the mayor refused to say whether he would insist on controlling a majority of the civilian board. Nor would he say whether its members should be elected.

“If I get ahead of the community groups, I’ll look like I’m not working with them,” he said.

As for the police officers who view the new, multi-tiered system of police accountability as a kangaroo court, the mayor is well aware he has a problem on his hands.

“Police will be as effective as the trust within the city. When it’s frayed, safety is frayed,” Emanuel said.

Asked how he plans to convince police officers who are already laying back for fear of being caught on the next YouTube video that the new system will be fair to them, Emanuel talked about changes approved Wednesday as being part of a “mosaic.”

“It’s not just this…You know the training we’re doing on de-escalation and the training we’re doing on mental health? That is what they asked for. Tasers and the training around the Tasers—that’s what they asked for. The additional resources I’m gonna put into the Police Department on manpower? They had asked for that,” he said.

“It is not just about this . . . . If you isolate it to this, they’re gonna express their concerns. But everything else they have looked at and now see that it’s the right thing to do . . . . Change can be frightening. We’re asking our officers to do a lot of change appropriately. It’s going to happen, and it’s the right thing that has to happen.”

During the debate, Ald. Walter Burnett (27th), one of Emanuel’s staunchest black supporters in the City Council, applauded the mayor for doing what he failed to do during a dictatorial first term as mayor.

That is “taking a step back” and accepting input from scores of community groups, even though he was “brutalized and criticized for it,” as Burnett put it.

COPA will have a guaranteed budget of 1 percent of the Chicago Police Department’s budget, not including grant funding.

That’s roughly $14 million, $5.5 million more than an IPRA budget the police reform advocates have called so inadequate that it virtually guaranteed that investigations of police wrongdoing will drag on for months or years.

The increased budget is particularly important, considering COPA will inherit an expanded annual caseload that, under the mayor’s ordinance, will include false arrests, illegal searches, denials of counsel and other constitutional complaints.

To accommodate the new deputy inspector general for public safety, Inspector General Joe Ferguson’s budget will increase by $2.4 million — from one-tenth of 1 percent of the overall city budget to 0.14 percent.

On the Council floor, Ald. John Arena (45th) warned that the civilian review board yet to come also needs “real power and real funding. . . . If we fail at that, everything else will be for nothing.”