An unexpected turn for the worse in East Germany's relations with both West Germany and the United States may be shaping up in the aftermath of President Carter's visit Saturday to West Berlin in company with West German Chancellor Helmut Schmidt.

Both the Soviet Union and East Germany have protested Schmidt's presence in the Western sector of the divided city as a violation of the 1971 Four-Power Agreement on Berlin signed by the United States, France, Britain and the Soviet Union.

The Communists have long resisted Western efforts to strengthen the bonds between West Germany and West Berlin. Whereas the Allies interpret the 1971 agreement as a vehicle for promoting stronger official ties, the Communists read it differently.

They view Schmidt's presence in West Berlin in an official capacity as an attempt to increase the officials bonds between the two areas and routinely protest such visits. Just as routinely, the Allies reject the protests.

But irritation over the joint visit - in which Carter was sharply critical of East Germany's human rights record - became especially bitter yesterday when the official East German Communist Party newspaper devoted its whole front page to one of the most scathing attacks on West Germany in recent years.

Although the attack was limited to allegations of neo-Nazism and restrictions on civl rights in West Germany, it is being widely viewed as part of the escalating East-West clash over dissidents and a broadening Soviet-bloc counterattack against President Carter's renewed offensive in this field.

A rare personal attack on President Carter also appeared in a Leipzig newspaper, charging the president with holding up a new arms agreement, interfering in the internal affairs of the Soviet Union, and confusing his responsibilities of being president "with that delt of a Baptist Preacher."

The new tension follows East Germany's recent attempt to improve relations with the United States through such actions as sending the widely acclaimed Dresden art collection to the United States for display and the dispatch, for the first time, of three top-level Cabinet ministers to Washington last month.

It also comes at a time when both East and West Germans were expressing some optimism that a long delayed and politically significant new road to link West Berlin, isolated 110 miles inside West Germany, with Hambrug, in West Germany might finally move ahead.

When Schmidt came to West Berlin, however the Communists shut down road traffic into the city for a few hours, provoking sharp protests from Carter and the other allies.

The president has pointed out that East Germany - not a [WORD ILLEGIBLE]of the Four-Power Agreement concerning Berlin - had no right to act or comment on the situation.

The president said it was his understanding that the Four-Power Agreement encourages stronger political ties between West Berlin and West Germany, even though the agreement does not allow the actual political inclusion of West Berlin as a federal state of West Germany.

"It is under that kind of understanding," the president told a West Berlin "town meeting" audience Saturday, "that Chancellor Schmidt is here with me today. I want to make sure that the strongest possible ties are encouraged between West Berlin and the Federal Republic of Germany.

Although the 1971 agreement by and large has worked well and has defused much of the Cold War tension over Berlin, the agreement is in fact quite vague, and in the past two years both the Soviets and East Germany have been assaulting Western interpretations and eroding Western rights in all sectors of the city.

The East Germans, for example, interpret the word "ties" to mean road-ways and transport links rather than political ties.

They also maintain that the whole 1971 agreement applies only to the Western sectors and not to the Soviet zone, which they say is the capital of East Germany.

The agreement, in fact, does not actually refer to all of Berlin. Part One of the agreement, which deals with general provisions, and which the Allies interpret as meaning greater Berlin, actually refers only to "the relevant area."

Part Two of the agreement - which includes provisions for unimpeded traffic through East Germany to West Berlin - relates only to the three Western sectors.

The leaders of the three World War II Allied powers, and of West Germany, met here at breakfast yesterday to discuss the Berlin situation, but no statement was issued afterwards, possibly a sign of an attempt to cool things off.