With expressions of hope and optimism and samples of the Lincolnesque oratory that propelled him to national prominence, Edmund S. Muskie last night became the nation's 58th secretary of state.

Muskie took the oath of office in the East Room of the White House before President Carter and about 500 members of Congress, past and present high diplomatic officials and friends from back home in Maine. He will start to work in earnest today at a foreign policy breakfast with Carter and his other top advisers, followed by speeches and meetings at the State Department.

Tuesday morning Muskie will be off for Europe to meet foreign ministers of North Atlantic Treaty Organization countries in Brussels, and is to meet Soviet Minister Andrei A. Gromyko in Vienna next Friday. The Muskie-Gromyko meeting was announced officially in their two capitals yesterday.

State Department sources said the United States asked the Soviets only for the Friday session, making no reference in the diplomatic request to additional meetings of the two men later. Since next Friday's meeting is to be introductory, further Muskie-Gromyko talks are not ruled out within the next month or two, but neither is there an approved plan to hold them, the sources said.

Muskie, a powerful political figure after 22 years in the Senate and major campaigns for president and vice president, came to the aid of Carter in a moment of crisis by accepting the post of secretary of state after Cyrus R. Vance resigned in protest against the use of U.S. military force in Iran.

A grateful Carter, reflecting this situation, began last night's ceremony by declaring that, "It's been a long time since I've seen as much excitement, happiness and gratitude in this room."

Neither Carter nor Muskie made any public reference to Vance. Although several former secretaries of state were present, including William P. Rogers and Henry Kissinger, Vance was far away in the Caribbean on vacation.

Carter spoke of Muskie, who was assuming "the highest position in my Cabinet," as the personification of the national character and "a man of vision . . . reason . . . conscience . . . great sensitivity and great knowledge about our nation and our people."

The veteran Maine senator, in reply, appeared to be carving out a semi-autonomous position, speaking of the direction and attributes of his administration in ways more typical of presidents than of Cabinet members.

He began by referring facetiously to charges of error-prone diplomacy, saying, "I'm not sure that I'm comfortable that you and I will be making mistakes together, Mr. President." Carter laughed, but also noticeably reddened.

Muskie then spoke of the resources, he brings to the office that is expected to cap his long career. One attribute is "the great good will . . . so unexpectedly accorded" by his fellow members of Congress and the public at large. "I'm not entirely sure why, and I'm not inclined to inquire too closely, but at least I have it," he said with the mixture of pride and self-deprecation that marks his political oratory.

He conceded that he is not an expert on foreign policy, but spoke of his skills of negotiation and compromise in other areas. "If foreign policy means the relationship between governments and countries and peoples, which must be adjusted in some fashion to minimize the prospect of violence and maximize the prospects of peace, that kind of exposure has been my life," Muskie said.

He said that in a lifetime in politics, he learned this above all: "If you believe in something, speak up -- and that I intend to do."

Muskie insisted, in the face of widespread charges of incomprehensible policy reversals in recent months, that "there's got to be clarity, there's got to be certainty, there's got to be a clear sense of direction."

He said he will relish the job, which he undertakes today "with hope and optimism."