Yugoslav writer Mihajlo Mihajlov celebrated his early release from prison under a government amnesty by saying that he intends to continue to speak out - whatever the consequences.

In an interview last night just a few hours after leaving Sremska Mitrovica jail northwest of Belgrade, Mihajlov said he is prepared to return to prison at any time.

"I am a writer and a publicist, and just as an opera singer wants only to sing, so do I only want to say what I think."

As a result of three prison sentences, Mihajlov has become Yugoslavia's best-known dissident after Milovan Djilas, the former vice president who fell from power and was sentenced to prison after writing a series of articles in 1954 criticizing the Yugoslav government.

Mihajlov, looking fit still dressed in his baggy light-green prison uniform, was freed after serving three years of a seven-year sentence for allegedly spreading hostile propaganda. The Amnesty will benefit a total of 218 potical prisoners - some of whom will be freed, while the sentences of others will be reduced.

Speaking at his lawyer's house, the 42-year-old writer said he heard of the amnesty Thursday night while listening to a foreign radio station. After his release, he packed his bags and caught a bus for the 40-mile trip to Belgrade.

He later called on Djilas at the latter's Belgrade apartment. Djilas wrote articles supporting Mihajlov while he was in prison.

Asked why he thought the Yugoslav government had decided on an amnesty for political prisoners at this tme, Mihajlov singled out President Carter's human rights campaign and the Belgrade conference reviewing the Helsinki accord as special factors. "This is the first success of the Belgrade conference. I am sure we would not have been released had it not been for the conference," he said.

[Carter thanked Yugoslavia Friday for the "wise and generous act" of granting the amnesty.]

["The President expressed gratification on learning that the Yugoslav government will grant amnesty to more than 700 prisoners, including some 200 who have been charged with political offenses," said a statement released at Camp David by White House press secretary Jody Powell. "The President termed the releases a wise and generous act," Powell said.]

Mihajlov also thanked the individuals and human rights groups in the West who campaigned for his release in appeals sent to President Tito. He particularly mentioned the London-based organization, Amnesty International.

Mihajlov was virtually unknown until 1965 when he received his first prison sentence of nine months for writing a book called "Moscow Summer".

The book, published in the West after being banned in Yugoslavia, was critical of the Soviet Union and drew strong Soviet protests. Mihajlov's subsequent arrest attracted worldwide attention.

He was sentenced again in 1966 on charges of hostile activity and served a three-and-a-half year sentence.

He was convicted again in February, 1975, when he was given a seven-year term for articles published in Soviet emigre publications and in the New York Times. He attributed the sentence to the government's feeling it needed to maintain a balance during a period when many pro-Soviet dissidents wer being arrested and tried.

Observes view Mihajlov, who has been in an out of jail for the last 12 years, as a kind of barometer of the political climate in Yugoslavia. His release has been interpreted as a relaxation following a clampdown in the early 1970s against liberalism and Croat nationalism.

Mihajlov said he has been offered work as a lecturer in Russian and Serbo-Croat literature at George Washington University in the United States, but said he wanted to remain in Yugoslavia.

Elsewhere there were these developments reported by press associations :

In Moscow, police beat an unidentified man after he tried to enter the U.S. embassy's commercial office as his children screamed "Save us! Save our father."

The police finally forced the man into an unmarked car, embassy sources said. They said that a group of 10 persons tried to enter the building, but that several were hustled off before the beating began.

In Rome, the second international "Sakharov hearing" received a message from Soviet physicist Andrei Sakharov, 1975 Nobel Peace Prize winer, urging that the hearing's findings be sent to the East-West conference now in session in Belgrade.

Sakharov - after whom this and an earlier inquiry in Copenhagen were named - asked that the inquiry examine alleged forced labor, torture, arbitrary and cruel punishments and violations of religious freedom in the Soviet Union.