A federal judge has upheld a controversial minority-hiring plan in Birmingham, Ala., rejecting the Justice Department's contention that the city is discriminating against white employes.

U.S. District Court Judge Sam C. Pointer Jr., in a ruling late Friday, said that a 1981 consent decree allows Birmingham to hire and promote blacks and women in municipal jobs over more qualified white male candidates. He said the agreement is a valid defense against charges of discrimination.

The case attracted considerable attention because of charges that the Justice Department "switched sides" by taking up the cause of white city employes, who charged that they have been victims of reverse discrimination.

The ruling is a setback for the Reagan administration, which has tried with little success to overturn 51 affirmative-action consent decrees previously negotiated with city governments. Many of these cities, including some governed by Republican mayors, are fighting the Justice Department in court.

However, the ruling is not a sweeping precedent because it was limited to the consent decree at hand and because the Supreme Court is scheduled to clarify its position on the politically sensitive subject next year. Also, the verdict is likely to be appealed.

Pointer ruled that "if the city of Birmingham made promotions to blacks . . . because the city believed it was required to do so by the consent decree . . . then they would not be guilty of racial discrimination.

"Even if the burden of proof be placed on the defendants, they have carried that proof and that burden of establishing that the promotions of the black individuals in this case were in fact required by the terms of the consent decree," the judge said.

Birmingham is a majority-black city with a long history of discrimination. Before 1974, when the first lawsuit challenging city hiring practices was filed, only two of the fire department's 640 employes were black.

The litigation was resolved with a 1981 consent decree, signed by both the city and the Justice Department, in which Birmingham promised to meet minority-hiring goals by giving preference to blacks and women. The agreement was signed shortly before William Bradford Reynolds, who opposes race-conscious remedies, became head of the department's Civil Rights Division.

When white city employes challenged the consent decree, the Civil Rights Division reentered the case on their behalf, charging that the city had gone beyond the terms of the agreement and was illegally favoring minorities.

But in a highly unusual deposition, Richard J. Ritter, the Justice Department lawyer who negotiated the 1981 agreement, appeared to side with city officials. Ritter said that "we certainly anticipated" that Birmingham would give preference to some less-qualified blacks and women, and that the city "would be permitted" to do this to meet hiring goals.

"The judge has decided that this consent decree should continue operating in the manner it was intended," said Stephen J. Spitz of the Lawyers Committee for Civil Rights Under Law, which represents some black plaintiffs in the case. He called the ruling "a rejection of the revisionist view that the Justice Department has adopted."

Justice officials have said their position has been consistent and that the decree does not allow the city to hire and promote less-qualified minorities solely on the basis of race.