Spain's post-France leaders in a move to build broad consensus for parliamentary system, will hold a referendum next month on a new constitution to cap the transition to democracy after four decades of dictatorship.

Once approved, the charter would usher in a new political era here with the parliament getting ultimate control over domestic and foreign policies, including Spain's military agreement with the United States and possible Spanish participation in NATO.

Until his death in 1975, such matters were decided by Generalissimo Francisco Franco.

Since Franco's death, foreign policy has been handled by the Cabinet while the bicameral parliament elected in 1977 drafted by law constitution.

The long and complex constitution, was completed in a series of compromised involving all political parties, including the recently legalized Communist Party.

It was overwhelmingly approved by the parliament earlier this week and political leaders are now hoping for a massive "yes" vote in the referendum.

Neither NATO nor the U.S.-Spanish bases treaty will be an issue in the referendum as no political leader - least of all Premier Adolfo Suarez - wants the campaign to be clouded by these issues.

The current bases agreement expires in 1981. Spain is not a member of NATO although it is linked to the alliance through military ties with the United States.

Suarez has made it repeatedly clear in public and private statements that he and his party favor Spain's membership in NATO and that the 25-year-old military relationship with the United States should be extended.

He deliberately has avoided making any move toward joining NATO for fear of breaking the parliamentary consensus with Socialists and Communists, and endangering the delicate balance of power that led to the writing and passage of Spain's 11th constitution since 1808.

For this reason, the United States which would like to see Spain in the Western alliance, has refrained from pressuring either the premier or King Juan Carlos, who as chief of the armed forces is said to favor early entry.

The premier heads a minority government that can count on 162 votes in the 350-seat lower house. He still has to decide whether to dissolve the present parliament, whose mandate ends in 1981, following the constitutional referendum.

Opposed to NATO are the Socialists, Spain's second largest political force. The party leadership has talked of re-negotiating the U.S. treaty, but many Socialist voters are opposed to the U.S. presence in Spain and express a desire to end the relationship which began during Franco's reign.

The Socialists have shown considerable strength in recent public opinon polls. Some Spanish political analysts think the party is in a good position to win any future general and municipal elections.

The Communist Party, which has collaborated closely with the premier in drafting the charter, is not for NATO, either. The small party, headed by Eurocommunist Santiago Carrillo, has been equivocal on the U.S. bases treaty.

The party's parliamentary strength is small, but Carrillo's influence is such that he could well determine the fate of NATO membership and of the U.S. bases.

Spain is now - and will be for some time to come - in the position of a pleader at the door of the European Economic Community. France and Italy, despite protestations to the contrary, fear competition from Spanish agricultural products, including wines. Apart from the agriculture issue Spanish industry is not in a position to complete against its Western European neighbors.

The Common Market's foot-dragging on Spain's membership application has miffed Spanish officials. Senior officials complain, "When Franco was alive, we were told to become a democracy. Now that we're a democracy and have a constitution to prove it, the West Europeans still tell us it's a question of tomatoes, onions and wine."

There are indications, however, that Common Market nations still want Spain to demonstrate that it is really on the way to full democracy. This means elections for the new bicameral parliament and for city governments, most of which are still controlled by Franco era holdovers.

The constitution is a mixed bag of progressive measures and general principles. It guarantees freedom and it abolishes the death penalty. It institutionalizes democracy in Spain for the first time since the 1938-39 civil war, and it opens the way for the final dismantling of the France dictatorship.

To be sure, the document pleases Socialists and Communists because it gives them a voice that was gagged by Franco for 36 years. But it is opposed by conservatives, by the extreme right and the extreme left, and by Basque separatists.

There is no question that party rivalries, which remained submerged during the long process of hammering out the constitution, will emerge in full force after the referendum. This will be a new and potentially difficult experience for Spain, which has not felt the heat of political and ideological debate since 1931.

The Socialists, who taste power, are certain to demand early parliamentary and municipal elections. Socialist General Secretary Felipe Gonzaloz has stated that "consensus politics are over."

The Communists keep plugging for a center-elft coalition as the only viable way to give roots to democracy in Spain. They appear to favor Suarez, who has been their main protector. Communist leader Carrillo is critical of the Socialists for seeking power so soon.

There is fear both in Spain and in Western Europe that should the Socialists win parliamentary and municipal elections, the deeply entrenched military establishment and the pro-Franco bureaucracy will make it difficult for them to rule.

While the tendency now is to downplay the political power of the military, there is no question that many generals, particularly those who fought for France in the 1936-39 civil war, view the institution of democracy with serious misgivings.