Supervisor Dianne Feinstein, whose collected and compassionate voice has been urging this city back to life since the slaying last Monday of Mayor George Moscone and Supervisor Harvey Milk, was elected by her colleagues today to fill Moscone's seat until an election next year.

She took the oath of office in an extraordinary swearing-in ceremony conducted by state Supreme Court Chief Justice Rose Bird. The two women, who between them now command an enormous amount of power in California, repeated the oath: "... that I will support and defend the constitution of the United States and the constitution of the State of California..."

Then Bird said, "congratulations," Feinstein smiled publicly for what seemed like the first time in this grief-sodden week, and the audience in the packed City Hall chamber rose in a standing ovation.

Feinstein has several opportunities resulting from her entry into the mayor's office. She must appoint three supervisors to the seats vacated by herself, Milk and Dan White, who resigned his post last month and is accused of murdering Moscone and Milk. Despite her strong and controversial opposition to San Francisco's newly approved policy of electing supervisors by district, Feinstein must select one successor from each of the now leaderless districts -- a process already begun in Milk's district, where Feinstein has said she will appoint another homosexual. She added today that in White's district she will appoint the man selected by Moscone to succeed White.

The sudden shift in political fortunes for the 45-year-old San Francisco native, who graduated from a Catholic high school here and today became the first woman mayor in San Francisco history, could scarcely have arrived with more sad irony. In May 1975, the opening month of her second unsuccessful campaign for mayor, Feinstein declared, "I will dedicate myself to reestablishing freedom from the tyranny of crime, freedom to enjoy our homes and freedom to walk the streets in safety."

Feinstein lost that campaign to then-state senator Moscone, who, with Milk, was killed at City Hall last Minday. Feinstein, as board president, automatically became acting mayor, and at today's supervisors' meeting she was officially elected, 6 to 2, to the $56,000-per-year post.

A Stanford history and political science graduate, Feinstein has an image as a political moderate -- her opponents call her conservative -- whose most vocal battles have been against organized labor. During two strikes by city employes in the 1970s, she was sharply critical both of the strikers and their salary demands, saying during the 1975 police strike, "unlike New York, we are going to say no to more city spending... In no way is this board going to concede to exorbitant demands because of an illegal strike."

For that reason, and because she is considered a strong supporter of business (welcoming, for example, the impending arrival in San Francisco of Neiman-Marcus, a store viewed by labor officials here as strongly antilabor), Feinstein received a less than enthusiastic welcome as mayor from the San Francisco Council of Labor. "We were disappointed in her position and her lack of sensitivity to some of our city employes during our turmoil out here," said John Crowley, secretary-treasurer of the council. "However, we wish her well... We just hope for the best."

Feinstein's tenure as supervisor has not been altogether unexciting since she was elected in 1970, despite her image as an unflappable politician who has occasionally alienated voters with coolness. The weekend before the slayings, she returned from a vacation in Nepal -- she had hoped to reach a mountain base camp there but became ill and was forced to ride back, reportedly astride a female yak. Some weeks before, she left her car to administer mouth-to-mouth resuscitation to a 74-year-old man who had collapsed on the street from a fatal heart attack.

An in October, at the opening of a restaurant and shopping complex on the waterfront, Feinstein's arrival was much publicized because she had promised the developer that if he made deadline she would show up in a bikini. He did, and Feinstein did show up -- but wearing a tan body stocking and a turn-of-the-century bathing costume, explaining that since only half the shops were open she was keeping only half the bargain.

In her first official news conference today as mayor, she said that although she had been considered more conservative than Moscone, she has no plans to replace city officials appointed by him, and would do her best to work with them.

Asked what philosophic difference her administration might have, she replied, "I will review what is working, efficient and doing what it's supposed to do... that it's a bona fide effort at doing something government ought to be doing."