The District of Columbia's strict gun control law was upheld by a D.C. Superior Court judge yesterday in the face of a challenge from the National Rifle Association and others that it was unconstitutional and discriminatory.

The ruling by Judge George Herbert Goodrich leaves the law - one of the toughest in the nation - in tact except for one provision.This provision would have allowed nonresidents of the city to carry firearms into the District for "any lawful recreational firearm-related activity."

Goodrich found this to be unconstitutional discrimination as between District residents and others because it permitted nonresidents to do something that some District residents cannot do under the law.

Otherwise, his ruling left standing an order issued by the D.C. Court of Appeals Feb. 4 upholding the law. The appeals court found that the City Council was within the powers granted to it by the home rule bill passed by Congress in 1974 in enacting the regulations.

The law requires that all guns owned by District residents be registered with the metropolitan police. It forbids the acquisition of handguns by District residents after the law took effect. It requires that handguns and other firearms already owned and registered be kept disassembled or fitted with trigger locks except when in use. Exceptions are firearms kept the merchants for self-defense and weapons used by private guards who have commissioned as special policemen.

Owners of unregistered weapons are liable to a $300 fine and 100 days in jail under the law.

The challenge to the legislation was brought by nine private citizens and two firms in addition to the Institute for Legislative Action of the National Rifle Association. Their attorneys said they were considering appealing Judge Goodrich's ruling.

The deadline for registering handguns and other firearms under the alw expired last Sunday, according to police spokesman. He said those who have failed to register weapons may still turn them into the police department to be destroyed or may sell them through licensed dealers outside the District.

The NRA and the other plaintiffs asserted that the City Council had exceeded its authority in passing the law. They said that the home rule charter reserved to Congress the power to change the city's criminal code.

Attorneys for the District government and for the National Council to Control Handguns, which entered the case as a friend of the court, asserted that the Council was changing police regulations and not the criminal code when it acted.

In his opinion and order, Judge Goodrich said: "It is the opinion of this court that Congress did not intend to limit the Council to the precise terms of (the criminal code) regarding regulations concerning the District's purely local police power."

Goodrich thush echoed the ruling Feb. 4 of the D.C. Court of Appeals.