The Supreme Court, over the objections of organized labor and industry, yesterday ruled that cities may impose residency requirements on their employes and on employes of city contractors.

Hiring preferences for residents are used increasingly to improve job opportunities for minorities and the shaky tax bases and economies of large cities, including the District of Columbia, but were under attack as "economic protectionism" forbidden by the Constitution.

Justice William H. Rehnquist, writing for the court in the case of White et al vs. Massachusetts Council of Construction Employers Inc. et al, said that state and local governments have no constitutional obligation to non-residents when hiring employes, either directly, as part of a municipal work force, or indirectly, through contractors.

Two justices, Harry A. Blackmun and Byron R. White, objected strenuously to allowing the preferences to be imposed on contractors, saying the practice illegally interferes with private employers and their employes and smacks of "parochial favoritism" forbidden by the Constitution.

In addition to its importance for the nation's cities, the case was crucial to civil rights organizations, which said it is essential to increase minority employment, and to employers and unions in the construction industry, which said requirements unfairly restrict their traditionally mobile labor pool.

The challenge was brought to the court by the Massachusetts Council of Contruction Employers and the construction unions in Boston after Mayor Kevin H. White required that at least 50 percent of the work on any construction project receiving city funds be done by Boston residents.

The Supreme Judicial Court of Massachusetts invalidated the quota on the grounds that it was forbidden by the Constitution's ban on interference with interstate commerce. The justices reversed that ruling yesterday.

Rehnquist said that the commerce clause of the Constitution does not apply when a city is "participating" in the labor market as an employer. Then, the city may set its own conditions without concern for the impact on non-residents.

The clause would apply, he said, if a government was acting to "regulate" the wider labor market by imposing a residency requirement on a business not receiving city funds.

He acknowledged that the workers employed by construction contractors in Boston were not really city employes. But "in this case," he said, "everyone affected" in Boston was "in a substantial if informal sense, 'working for the city.' "

He also cautioned governments not to reach too far in imposing hiring preferences on "employment contracts between public contractors and their employes . . . . There are some limits," he said, "on a state or local government's ability to impose restrictions that reach beyond the immediate parties with which the government transacts business."

Addressing another element of the case, Rehnquist noted that any residency requirement imposed or suggested by Congress when appropriating funds for federal projects easily passes constitutional muster because of Congress' power to regulate interstate commerce.

Blackmun and White concurred with that part of Rehnquist's ruling and with residency requirements for actual city employes. But they objected to imposing it on a private work force.

The 1979 Boston order, Blackmun wrote, "directly restricts the ability of private employers to hire nonresidents, and thereby curtails nonresidents' access to jobs with private employers. I had thought it well established that, under the commerce clause, states and localities cannot impose restrictions granting their own residents either the exclusive right, or a priority, to private sector economic opportunities."

He said the order was "a direct attempt to govern private economic relationships."

The AFL-CIO and the United States Chamber of Commerce were united in opposition to the residency requirements. The labor federation told the court that the requirements "balkanize" job and business markets. The chamber said that they "disrupt the free trade among the states upon which the economy of this country is built."

In other action yesterday, the court said it would hear arguments next term on a federal law barring public broadcast stations from running editorials.

U.S. District Court Judge Malcolm Lucas of Los Angeles ruled last August in FCC vs. League of Women Voters of California et al that the ban violated free speech rights.