In the first civil rights case brought by the Reagan administration, the Justice Department won an agreement yesterday from the city of Statesville, N.C., to desegregrate its all-white police and fire departments so that blacks eventually make up 18 percent of the two forces.

The city, which has a population of about 21,000, must hire blacks for one third of its police and fire department openings each year until it reaches the 18 percent goal. The Justice Department and the city agreed on the 18 percent figure because blacks comprise about 18 percent of the city's overall labor force.

An employment discrimination suit and the proposed consent decree were both filed yesterday in U.S. District Court in Rutherfordton, N.C., which will rule on final approval of the consent decree. The civil suit charged that the city and its officials violated the Civil Rights Act, the Revenue Sharing Act, the Law Enforcement Funding Act and the Intergovernmental Anti-Recession Assistance Act by discriminating against blacks seeking jobs as firefighters and police officers.

The suit was the first civil rights action by Attorney General William French Smith, who inherited the investigation from former attorney general Benjamin R. Civiletti but brought the action on his own.

The investigation began when a fired black fireman named Carlton P. McClelland complained to the Equal Employment Opportunity Commission that he was denied promotion to lieutenant because he was black.

As of May 1980, when the Justice Department began its investigation, there were no blacks among the city's 57 police officers and 58 firefighters. McClelland had been the only black ever hired by the Statesville Fire Department. There had been two black policemen in Statesville, both of whom quit the force more than three years ago.

Under the consent decree, Statesville also agreed to promote blacks in proportion to the number of hired blacks eligible for promotion to as many as 18 percent of the promotion vacancies.