The Supreme Court ruled yesterday that trade unions may prohibit nonmember contributions to internal union leadership campaigns. The ruling is expected to make it harder for dissidents to challenge established union officers.

The 5-to-4 decision, limiting free speech protections for unionists under federal labor law, stemmed from the 1977 Steelworkers union election race between Edward Sadlowski Jr., a "dissident" candidate, and Lloyd McBride, who was endorsed by most of the incumbent union leaders and ultimately won the contest.

Sadlowski, whose campaign became a popular cause among liberal activists, received numerous contributions from outside the union. After the election, the 1978 Steelworkers convention moved to prevent such challenges in the future by creating an "outsiders" rule, barring contributions by nonmembers.

Sadlowski and his allies challenged the outsiders rule, saying it violated the Labor-Management Reporting and Disclosure Act's provision guaranteeing free speech to union members.

Reversing the U.S. Court of Appeals here, Justice Thurgood Marshall wrote for the majority that the free speech provision is not as broad as the First Amendment protections of the Constitution. The union need only show, and it has shown, that its rule is "rationally related" to its interest in reducing outsider interference, he said.

Justice Byron R. White, joined by Chief Justice Warren E. Burger and Justices William J. Brennan Jr. and Harry A. Blackmun, dissented in United Steelworkers of America vs. Edward Sadlowski Jr., et al.

White said the outsiders rule was not, in fact, a reasonable one. Congress, he wrote, was concerned about corrupt and entrenched leadership maintaining a grip on union offices when it passed the law in 1959 following revelations and hearings concerning the Teamsters and Bakery and Confectionary Workers unions.

Restrictions such as the outsiders rule in the Steelworkers union "are a far cry from the free and open elections that Congress anticipated and are wholly inconsistent with the way elections have been run in this country," White wrote.

In other action yesterday:

In a unanimous judgment, the court made it more difficult to bring broad-ranging employment discrimination class-action suits in federal court.

The case stemmed from a discrimination complaint against the General Telephone Co. of the Southwest brought by a Mexican-American employe, Mariano S. Falcon. Falcon sued over alleged discrimination in promotions within the company, but claimed also to represent a class of Mexican-Americans victimized by hiring discrimination.

Justice John Paul Stevens, writing for the court, said Falcon could not, under federal rules governing class actions, represent those never hired by the company since he had been hired. The justices reversed a ruling of the 5th U.S. Circuit Court of Appeals.

The court ruled 8 to 1 that Alaska, now overflowing with state revenue from oil and minerals, may not discriminate in distributing that money on the basis of length of residence in the state.

The ruling, written by Burger, was a victory for Ronald and Patricia Zobel, who moved to Alaska in 1978 and received $800 less in state natural resource "dividends" than persons residing in Alaska since 1959. Justice William H. Rehnquist dissented.

The court said it would decide whether the late billionaire Howard Hughes resided in California or Texas for estate tax purposes. The outcome is worth millions of dollars.

The court chose to consider the issue under its authority to hear disputes between two states, rejecting a lower court's decision to resolve the matter under a suit brought by the administrator of Hughes' estate.