OAKLAND, Calif. -- Long a poster child of high crime, Oakland is preparing to lay off nearly a fifth of its police force just as it has turned the corner on crime, part of a national trend in the recession.

This city of 400,000 said last month it would cut 140 officers from its 800-strong police force, the department's first-ever mass layoffs.

Dozens of hard-hit cities have done the same. In May, Toledo, Ohio, laid off 11% of its police force. In Minnesota, seven city police departments have closed since March, and state officials say an additional nine departments are likely to close by year's end.

The Oakland cuts, to take effect in September, come after the city spent the past five years building its police force to the highest number of officers it had ever seen. The buildup is credited with helping to lower the city's number of homicides by about 20% and cut its violent crime by about 13% over the past year.

To hang onto those gains, Oakland has tried for months to protect police from cutbacks. Faced with an $83 million budget deficit, Oakland lawmakers instead closed City Hall one day a month, trimmed the city attorney's budget 10%, reduced Mayor Ron Dellums's staff by 20% and even grounded the police department's helicopter, saving the city about $400,000 annually.