A federal judge yesterday upheld the right of states to control oil drilling off their coasts, blocking the Interior Department from offering controversial leases in California's Santa Maria basin.

California Gov. Edmund G. (Jerry) Brown Jr. said the permanent injunction from U.S. District Court Judge Mariana Pfaelzer had "done what President Reagan should have done months ago: collared [Interior Secretary James G.] Watt and brought him to heel."

Brown called the decision on the area off picturesque central California "a crucial first step in the continuing fight against the despoiling of our scenic and natural resources."

Over Brown's objections, Watt decided in May to offer 32 tracts of land in Santa Maria basin for oil and gas leasing, and is considered similar and even more controversial action in four northern California coastal areas.

Brown and representatives of five state agencies argued in court thta oil leasing would harm marine mammal and bird habitats and would be inconsistent with California's coastal management plan. The Coastal Zone Management Act requires federal offshore actions to be consistent with state plans.

Judge Pfaelzer agreed with the latter point, reaffirming her May 28 preliminary injunction. The government, she said, had failed to prove that its leasing would not "directly affect" the coastal zone. She ordered that $220 million in bids already submitted be returned to the bidders.

However, she denied state contentions that the Interior Department had violated the National Environmental Protection Act, the Endangered Species Act and the Outer Continental Shelf Lands Act in the 32 areas. She allowed bidding in three areas where she ruled the Coastal Zone Management Act had not been violated.

Watt said he was pleased that the department won on three of the issues and that the other ruling would be appealed all the way to the Supreme Court if necessary. "Today's decision is but one step along that road," he said.