The Supreme Court yesterday unanimously upheld the constitutionality of the windfall profits tax on crude oil.

The action, reversing a lower court ruling, saves the government from having to refund about $26 billion paid by oil companies since the tax took effect in 1980. It also prevents a $50 billion revenue shortfall that would have occurred over the next five years had the tax been struck down by the justices.

The tax was designed to recapture the massive profits that accompanied the elimination of oil price controls. When Congress enacted the tax, however, oil produced above the Arctic Circle in Alaska was exempted. Drilling and exploration under those frozen conditions, it was felt, already were costly enough and would be discouraged by the imposition of the windfall profits tax.

Producers in other oil-producing states cried foul, saying the tax violated a provision of the Constitution requiring that federal taxes be applied uniformly from state to state, without geographical discrimination. A U.S. District Court judge in Wyoming struck down the tax. Yesterday's decision in U.S. vs. Ptasynski reversed the lower court.

Justice Lewis F. Powell Jr., writing for the court, said Congress has no obligation to guarantee that every tax affects every state in the same way. Nor is Congress barred from making geographical distinctions to recognize "geographically isolated problems," he said.

In the windfall profits law, he said, "Congress clearly viewed exempt Alaskan oil as a unique class of oil that . . . merited favorable treatment. It had before it ample evidence of the disproportionate costs and difficulties--the fragile ecology, the harsh environment, and the remote location--associated with extracting oil from this region," Powell said.

Powell noted that the Alaskan oil, which constituted about 20 percent of the state's total production, cost 15 times more to extract than oil from other states and even other parts of Alaska.

"We cannot fault its determination, based on neutral factors, that this oil required separate treatment," he said.

In other action yesterday:

* The justices struck down Tennesee's two-year statute of limitations on paternity suits involving children born out of wedlock.

The case orginated with a child support suit brought by Frances Annette Pickett against Braxton Brown, who she said was the father of her 10-year-old son. Brown, who denied paternity, got the suit thrown out because of the law requiring that such suits be filed within two years of birth unless state welfare money is at stake. No similar law covers suits brought on behalf of legitimate children.

Justice William J. Brennan Jr., writing for a unanimous court in Pickett vs. Brown, said the statute of limitations unconstitutionally denied equal treatment to illegitimate children.

He said the law "severely restricts" an illegitimate child's right to parental support. Many factors, including emotional strain and poverty, can delay a mother's effort to obtain support from a child's father, Brennan said.

He also rejected Tennesee's justification for the law: that it prevents "stale and fraudulent" claims. "There is no apparent reason why claims filed on behalf of illegitimate children who are receiving public assistance when they are more than 2 years old would not be just as stale, or as vulnerable to fraud, as claims filed on behalf of illegitimate children who are not public charges . . . ," he said.

* The court said it would again try to decide when traditional seniority rights may be ignored to protect minorities during layoffs.

The court agreed to review a "reverse discrimination" claim brought by the Memphis firefighters union after senior firefighters were laid off during a 1981 municipal budget crunch to preserve jobs for newly hired blacks.

Last month, the court dismissed a similar case involving police and firefighters in Boston because all those laid off there had been reinstated. Those laid off in Memphis also have been recalled, however, and that case--Firefighters Union No. 1784 vs. Stotts--also may be moot. The court will consider the case in its next term, which begins in October.

* The justices ruled that the federal government owns the rights to gravel on 33 million acres of privately held western land. The issue is of substantial importance to thousands of farmers and corporations that have been mining the gravel for their own use or selling it. The case, Watt vs. Western Nuclear Inc., turned on a 1916 law retaining the government's right to "minerals" on the land.

The court, in a 5-to-4 opinion written by Justice Thurgood Marshall, said gravel should be included in the definition of minerals. Justice Powell, joined by Justices William H. Rehnquist, John Paul Stevens and Sandra Day O'Connor, dissented.