Spain took a long stride toward reestablishing a parliamentary democracy today as nearly 20 million voters turned out to elect a national Parliament.

Isolated bombing incidents that injured six persons and electoral malfunctions in some areas failed to disrupt the orderly balloting for the Parliament, which is expected to write a few constitution for Spain within the next year.

An hour after the 38,000 polling stations had closed in the first free elections here since 1936, the government said about 80 percent of the electorate had gone to the polls. Substantial returns were not expected until early Thursday because of the complex system of vote distribution being used.

The calm of the balloting was in sharp contrast to the chaotic election of 1936, when leftist victories triggered an uprising by the army and the bloody three-year civil war that the forces of Generalissimo Francisco Franco eventually won.

Franco outlawed political parties and kept the Spanish Cortes, or Parliament, only as a rubber stamp for his own military rule until he died in November 1975.

Today's voting was the highpoint thus far of the cautious program Franco's personally chosen royal successor, King Juan Carlos, has embarked on to modernize the Spanish political system without yet yielding any significant amount of power to elected representatives.

The loosely knit Democratic Center coalition, led by the King's appointed prime minister, Adolfo Suarez, appeared to be in the strongest position to capture control of the Chamber of Deputies and the Senate.

The Democratic Center, made up of 12 right-of-center small parties hat banded together behind the 44-year-old prime minister, faced a strong challenge in the Chamber of Deputies from the Socialist Party led by 35-year-old Felipe Gonzalez, however.

The six other important political groupings in the race range from the neo-fascist New Force and the Francoist Popular Alliance led by Manuel Fraga on the right, to the Communist party of Santiago Carrillo on the left.

The Chamber of Deputies can originate legislation, but its actions can be blocked by the 248-member Senate, which is certain to be controlled by a combination of the king's 41 appointed members, whom he named tonight after the polls closed, and the conservative elected members.

The king, who retains the right to ignore the Cortes and rule by decree if he is willing to accept the political cost in domestic and international opinion, used one of his Senate appointments to install Antonio Hernandez Gil, a 62-year-old international law expert whom the king also named as president of the Cortes today.

The bombs exploded in the Basque northern provinces and Catalonia early today. One blast cut the Madrid-Paris railway briefly, for the second time in four days. Five men and a woman were arrested with explosive devices in a wooded area near the Basque city of Bilboa.

About a hundred polling stations in Madrid ran out of ballots during the day, and voting was extended at those places for 90 minutes after new supplies were rushed in.

Madrid and Barcelonia provinces, with electorates of about 3 million each, elected one deputy for every 100,000 registered voters. Farming areas such as Guadalajara and Soria were awarded one deputy for every 30,000 electors.

By winning in 15 provinces with a total of 3.5 million prBy winning in 15 provinces with a total of 3.5 million people, Suarez stood to pick up 53 seats in the Chamber, and to be able to write off Barcelona Province, with its 4.5 million inhabitants and 33 seats.

The often subtle but real advantages the conservative parties have in the countryside were apparent during the balloting in places like Chinchon, a town of 4,300 southwest of Madrid that has a plaque prominently displayed in the town plaza to commemorate a local landowner "vilely assasinated by Marxist hordes" in July 1936.

The families that live largely from rice and garlic crops moved steadily throughout the afternoon from their whitewashed stone houses up a steep hill to a spacious, modern schoolhouse.

Many had received ballots through the mail from the parties, or had been handed them by the local caciques , the town's most prominent landowners, and walked into the schoolhouse with envelopes for the Chamber and Senate already sealed. A complete range of ballots and a screened-off voting booth were also available inside the school.

Secrecy of voting appeared to be respected, but government policemen checked voter's credentials before allowing them into the school, and paramilitary Civil Guardsmen were also on the schoolgrounds. Some voters were asking the poll-watchers whom they should vote for.

"Suarez should win here," the head of the voting board, Juan Susiac, said in mid afternoon. "The people want clam."

"The voting has been fair and the campaign was clean here," said a communist schoolteacher observing the balloting in the schoolhouse. "We don't expect to win in small towns like this, but we should do well in the cities."

"If people voted for Suarez or Fraga, they come down here and say so," said a bartender. "If they didn't, they jsut keep quiet," he added, lowering his own voice to a soft murmur as he acknowledged that people were still relectant to voice political opinions strongly in the town.

Opposition leaders announced as they voted that they were satisfied with the election and the campaign, which Socialist leader Gonzalez said had been "short, but moderate, clean and dominated by great civic sense of responsibility."

Squarez went into the balloting with powerful advantages over his rivals above and beyond the king's tacit support and an aura of American support provided by well-publicized meetings in the past two months with President Carter and Vice President Mondale.

The electoral arithmetic ran heavily in Squarez' favor.

The 350 seats in the Chamber of Deputies are divided on a weighted proportional representation system that awards extra seats to the party lists that pile up big margins in the 53 provinces voting.

The two biggest parties, the Demoncratic Center and the Socialists, stood to gain about equally from the top-heavy weighting system, while the smaller parties will get fewer seats than their popular-vote total would entitle them to in a straight proportional distribution.

Moreover, the electoral plan put through by Squarez' government gives bonus seats to the sparsely populated rural provinces that the prime minister had expectations of carryign easily.

Washington Post Special Correspondent Miguel Acoca reported:

Officials of the Spanish Socialist Workers' Party complained that in many Madrid area and suburbs where the left is strong, polling stations did not receive ballots and the voting had to be delayed for at least two hours.

Communists made similar complaints. Margarita Garcia, 21, a "sympathizer" who cast her first vote for the party, said she had been "frightened" by the presence of police at a school. She claimed that many unable to vote becaue their names did not appear on the census lists, which is equivalent to being registered to vote in the United States.

"There was a lot of shouting," she said. "For a moment I thought the police were going to crack heads."

A party spokesman charged that many Communist ballots were spoiled because "rightists" wrote "bastard" and "murderer" after the names of Communist candidates.

But it wasn't only the left that was affected by the shortage of ballots. In many polling stations ballots for right-wing parties were not available. Two cabinet ministers were forced to wait for nearly 90 minutes while ballots were delivered. Late this afternoon the government ordered the printing of thousands of new ballots to make up for the mysterious shortages.

Carlos Hernandez, 65. Popular Alliance poll watcher, rushed out of a school in an upper-middle-class Madrid residential area after casting his vote.

"I'm headed for Torrejon de Ardoz [a Communist stronghold] to make sure that the Reds don't pack the ballot boxes," he said. "This election is a pity. We don't need it. All we had to do was to make a few reforms to what Franco left us. We defeated the Communists in the Civil War. Why shoud we let them vote?"