A federal judge yesterday approved a $33 million plan to provide a wide range of community-based mental health services for treatment of patients needlessly confined at St. Elizabeths Hospital. It also would involve other residents whose mental health problems can be met outside the confines of the hospital.

The plan was signed by U.S. District Judge Aubrey E. Robinson Jr., who ruled in 1975 that patients at St. Elizabeths have a legal right to care and treatment in facilities that are less restrictive than the hospital.

Robinson acted in a lawsuit brought in 1974 by patients at St. Elizabeths who sued both the federal and District governments in an effort to stop inappropriate long-term confinements at the hospital. Lawyers on both sides of the case have been negotiating details of the plan for community-based services for more than four years. The patients were represented by attorneys from the Mental Health Law Project.

The plan provides for a long list of mental health services to be made available by October 1982, including nursing homes and group homes for patients who need residential care, day care programs, drug therapy, homemaker services, occupational training, sheltered workshops and placement in special, private employment.

The city government is obligated by the terms of the agreement to come up with $17.2 million from fiscal year 1980 through 1982 to pay its share of the community-based services. In addition, St. Elizabeths will reallocate $8 million of its current budget toward the plan and the District government and the hospital will seek another $8 million in federal funds to carry out the projects.

The city and the hospital have agreed under the plan to make community-based residential facilities available by December 1981 to about 800 patients whom hospital officials have said are well enough for outpatient placement, according to Margaret F. Ewing, an attorney with the Mental Health Law Project. Nursing home care for patients who need psychiatric treatment must be provided by 1985, she said.

Additional community-based services outlined in the plan for implementation by October 1982 will serve 3,000 District residents now receiving some type of mental health care from the city, and another 3,000 outpatients who have been released by St. Elizabeths, Ewing said.

City officials could not be reached for comment yesterday on plans for financing the plan. Sources indicated that officials, in anticipation of court approval of the plan, have obtained a $2.4 million appropriation through an amendment to its 1980 budget for the new expenses. This would be $1 million less than had been requested from Congress.

It was unclear whether the District government's financial commitment to supply the mental health services would be affected by action at the House district Appropriations subcommittee, which recommended yesterday that the city receive only half of the $62 million Mayor Marion Barry said he needs to balance the city budget.

Ewing said the District's $17.2 million contribution is to be made in separate payments over the three-year period for the plan's implementation.