Delegates at the European security and cooperation talks here agreed today on a compromise final draft document and tentatively scheduled a July 18 closing session attended by the foreign ministers of the 35 participating states.

The agreement, which will wind up nearly three years of talks reviewing the 1975 Helsinki detente accords, now has to be referred to the governments of the participating nations--the United States, Canada and all the European states except Albania.

The informal endorsement of the draft document followed complex negotiations throughout the week to avoid a new deadlock. The negotiations centered on a compromise between the two blocs over a future meeting on the key Helsinki issue of human contacts between citizens of communist and noncommunist countries.

This meeting, which according to today's draft will be convened in Bern, Switzerland, in April 1986, is the result of tough western bargaining here to obtain safeguards on questions such as freedom of movement between the blocs and the reunification of families separated by the Iron Curtain.

To gain Soviet acceptance of the human contacts meeting, the mandate for it was included in an annex to the concluding document. Neutral-nation diplomats who conducted the negotiations said this was a face-saving device for the Soviet Union, which had long rejected such a meeting. But the move prompted concern among some western diplomats that the human contacts issue had been downgraded by being placed in an annex document.

To gain Soviet Bloc agreement to the final document, the West had to drop issues such as specific guarantees concerning free trade unions and the rights of East Bloc dissidents who monitor the implementation of the Helsinki human rights provisions. Also dropped from the draft final document were safeguards against radio jamming.

Diplomats in the western camp, however, viewed the proposed agreement, for all its shortcomings, as an improvement over the Helsinki language and as the best compromise that could be obtained at a conference overshadowed by the crises of Afghanistan and Poland.

In addition to the human contacts meeting, western delegates pointed to a mandate for a meeting scheduled for Ottawa in May 1985 to deal specifically with human rights.

A key outcome of the Madrid meeting is the agreement to hold a conference on disarmament in Europe in Stockholm in January 1984 attended by all the participating states. While this conference was originally an East Bloc initiative the final document incorporates western views on it by specifying that it will address itself solely to so-called confidence-building measures that aim to reduce the risk of surprise conventional military attacks in Europe.

The Stockholm conference is to establish the ground rules for the mandatory and verifiable notification of significant troop movements from the Atlantic to the Urals.

Today's session agreed on two further meetings next week to approve translations of the concluding papers and to adopt an agenda for the foreign ministers.

Diplomats of both blocs as well as neutrals said the only possible obstacle to final formal agreement was a demand by Malta for specific guarantees dealing with Mediterranean security.

The 35 states also agreed today to hold another Helsinki review conference in Vienna beginning in November 1986.