After nearly three years of negotiations, Athens and Washington initialed a new defense cooperation agreement today, in which the United States pledges $700 million in military assistance to Greece over a four-year period in exchange for the continued use of four strategic bases here.

The signing of the agreement, which reinforces U.S. presence in the volatile eastern Mediterranean, caught many diplomatic and Greek government officials by surprise. It followed turmoil over remarks by U.S. Ambassador-designate William Schaufele that only last week prompted the Greek government to suggest that the career diplomat's nomination be withdrawn.

"This is precisely the point," said a Foreign office official, "The timing is not peculiar at all. It is absoutely indispensible that we have good relations with America. And our government will not be dictated to by the opposition and its sensationalist to by the opposition and its sensationalist press."

After sharp criticism by the press and opposition political parties over allegedly pro-Turkish statements by Schaufele before the Senate Foreign Relations Committee on the Greek-Turkish dispute over the Aegean Sea, the government of Premier Constantine Karamanlis, which had approved Schanfele's nomination, requested that it be withdrawn.

The Greeks never declared Schaufele "persona non grata," according to ranking sources, but reportedly told Washington that his effectiveness would be limited because of the heated anti-American stand taken by the opposition and the often-sensationalistic Greek press.

Diplomatic sources have confirmed that the base agreement, initialed in principle by the two governments in April 1976, was ready for signature some months ago but withheld due to.

The key U.S. installations affected are an air base outside Athens, considered critical for Middle Eastern reconnassance fights; a communications station in central Greece; an electronic listening station outside Heraklion, on the island of Crete; and what has been described as the Mediterra-internal political pressures here.

nean's "most magnificant natural harbor" and airfield at Souda Bay, also on Crete.

According to the new agreement, all U.S. installations will be under a Greek commander during peacetime, any they will serve "only the purposes authorized by the government of Greece." Half the people stationed at the four incilities will, under the agreement, be Greeks.

Facilities housing nuclear weapons according to ranking sources, will remain under U.S. NATO command.

The agreement was drawn up intially to match a similar Washington-Ankara package, signed early last year, that committed the United States to provide more than a billion dollars in aid to Greece's adversary, Turkey, in exchange for military facilities, also over a period of four years.

Greek government officials then, and now, expressed concern that the Turkish commitment would tip the balance of power toward Ankara in the sensitive Aegean and Mediterranean Seas.

"It can certainly be viewed as an important foreign-policy victory for the Carter administration," a Western observer said of today's agreement "and it shows Karamanlis' determination to solidify direct links with Washington as a means of bringing stability to Greece, Turkey and Cyprus . . . It also shows his strength in facing potentially unpopular decisions."

A source close to the Greek prime minister said that Karamanlis felt it time for Greece to "stand up and be counted with the West."