For five years, Mayor Rahm Emanuel and other city officials hewed to the same script, maintaining to the public that Chicago has enough cops.

And the mayor and police brass proclaimed that they were working with the community to fight problems that lead to crime.

But out of the spotlight, the Emanuel administration told federal officials that the Chicago Police Department needed hundreds of additional officers and that community-based policing has been withering in Chicago for years — and that’s been a factor in the rise in violent crime battering the city.

In applications for grants from the Justice Department the past two years, city officials portrayed the Chicago Police Department as dangerously understaffed — even as Emanuel and police brass publicly dismissed calls to hire more cops until just a few weeks ago.

“The high number of unfilled sworn [police] positions, coupled with an unacceptably high rate of firearms-related violent crime in Chicago, continues to pose a significant public safety concern for our residents, the local economy and for the millions of tourists and visitors coming to Chicago each year,” reads a City Hall grant application submitted in July.

Earlier this month, the Justice Department awarded the city $3.1 million to pay for 25 police officers — the most allowed under the grant program. The city has gotten grants to fund police hiring every year that Emanuel has been in office, as it regularly did under his predecessor, Richard M. Daley.

During the 2015 campaign, mayoral challenger Jesus “Chuy” Garcia promised to expand the police ranks, saying he would pay for that by cutting the $100 million a year the police were spending on overtime. Emanuel ridiculed that idea.

Three months later, city officials told the Justice Department they wanted to hire 469 additional police officers but didn’t have the money. They reiterated that in another application this summer.

“Tragically, in particular Chicago communities and neighborhoods, public violence is ‘normal,’ and proximity to firearms-related incidents is an everyday fact of life,” city officials wrote in the July application.

Since taking office in 2011, Emanuel has said the police department remains committed to community policing — known here by the acronym CAPS, for Chicago Alternative Policing Strategy. First adopted in Chicago in the 1990s, the approach is based on residents and police sharing information and working together to solve problems that lead to crime.

From the superintendent to each beat officer, “Everybody practices community policing,” the mayor said during his 2015 campaign.

Yet, in that year’s city budget, the mayor had closed the CAPS office and cut funding for community policing staff to $2.7 million, down from $9 million in 2000 and $4 million when he came to City Hall, budget records show.

And in a grant application that summer — three months after Emanuel needed a runoff to win another term — city officials highlighted a different approach to policing. The “Gang Violence Reduction Strategy” focused on “suppression” in high-crime hot spots, they wrote. As evidence of its success, they pointed to a drop in citywide crime statistics.

A year later, crime was surging, with Chicago headed toward a year with more than 600 murders for the first time in more than a decade.

In July, city officials acknowledged to the Justice Department that the police department has drifted from community policing. No longer touting crime “suppression,” they wrote that years of “hot spot” policing had caused friction with some members of the community.

“While this model has been successful in preventing and reducing crime,” the application says, it also “led to some erosion of police officers’ understanding of the vital role community-based crime prevention strategies contribute to long-term, sustainable reductions in crime.”

It spelled out how little training officers receive once they leave the academy. Each year, police officers are given eight hours of training in the use of force — and none for conflict de-escalation, racial or ethnic bias, gender bias, sexual orientation bias or engagement with the community.

In his 2017 budget proposal, Emanuel wants to expand crisis-intervention training, create a community relations division in the police department and add 970 officers. Mayoral aides said the hiring costs would be covered by cutting police overtime.

Aldermen say the hiring is past due.

“Most of us are just trying to make sure it’s going to happen,” says Ald. Roderick Sawyer (6th), chairman of the Chicago City Council’s Black Caucus. “A few of us have been proposing this for years now.”