Stanley S. Harris, U.S. Attorney for the District of Columbia, said yesterday that he opposes passage of a measure on the Sept. 14 primary ballot that would impose mandatory sentences on persons convicted of committing violent crimes with a firearm and certain drug offenses.

The city's chief prosecutor, in an unusual public statement on a local political issue, said that the U.S. Attorney's office does support the idea of mandatory prison terms "in appropriate and carefully defined circumstances." Harris said, however, that his office has concluded that the proposed new law "is not crafted in such a way as to meet our concerns . . . ."

The U.S. Attorney's office is concerned, among other things, that judges will avoid the mandatory sentencing law, particularly for first offenders, by making more frequent use of the federal Youth Corrections Act, sources said yesterday.

That act provides that defendants under the age of 22 can be sentenced to indeterminate prison terms. The federal prosecutors also anticipate that a provision in the proposed law that would exempt drug addicts from mandatory prison terms would result in a mass of litigation at the time of sentencing from drug dealers trying to prove that they are addicts, sources said.

In opposing the ballot question, called Initiative 9, Harris joins a broad coalition of citizens, major civil rights organizations, civil liberties groups and local political leaders who have voiced disapproval of the measure.

Despite such opposition, an Associated Press/WRC-TV poll of 973 registered voters released last week showed that 71 percent favor the measure, 17 percent oppose it and 12 percent are undecided