Spanish officials said today they would not bend to terrorist demands as Madrid's central criminal court prepared to put on trial two Shiite Moslems, whose freedom is allegedly sought by the hijackers of Trans World Airlines Flight 847 as one of their conditions for the release of the American hostages in Beirut.

By coincidence, the trial of Mohamed Jahir Abbas Rahall and Mustafa Ali Jalil on charges of attempting to murder a Libyan diplomat in Madrid last September opens Wednesday with the drama of the hijacked aircraft as a backdrop. The date of the trial had been fixed last month and the court proceedings accordingly will begin under extremely heavy security precautions.

Both men are said to figure on lists issued by the Beirut hijackers along with the approximately 700 Shiite Moslems held by Israel. Officials, however, said they understood that the lists were not definite and that while the situation remained "fluid," they were unable to ascertain the priority accorded by the Beirut hijackers to Rahall and Jalil.

Spain's ambassador in Beirut, Pedro de Aristegui, together with the British and French ambassadors to Lebanon, is a member of the negotiating team in the hostage crisis and is in constant contact with the Foreign Ministry in Madrid.

In Madrid, Foreign Ministry spokesman Fernando Schwartz has stressed that Spain's consistent policy has been to reject terrorist blackmail. The point was underlined by Prime Minister Felipe Gonzalez yesterday when he met briefly with reporters.

Gonzalez, who has his own domestic terrorist problem with the the Basque separatist organization ETA, has been in the forefront of Western European politicians seeking international agreements to cooperate against terrorists.

Rahall and Jalil, who are both Lebanese citizens, were detained by police shortly after a Libyan diplomat, Mohamed Aidress Hammed, was shot and wounded in a residential area of Madrid. Police at the time spoke of a "smoking gun" arrest in the case and Madrid press reports said that the wounded diplomat was a member of the Libyan security service.

The state prosecutor is seeking prison terms totaling 36 years for the two Shiites on charges of attempted murder, membership in what the Spanish penal code calls "armed gangs" and illicit possession of firearms. A separate legal action on behalf of the Libyan Embassy is seeking 38-year jail sentences for the two.

The lawyer for the pair, Juan Manuel Olarieta, said today he would concede the attempted murder charge and plead that the two men receive the minimum six-year sentence under Spanish law. Olarieta, a lawyer attached to the prison of Alcala-Meco where Rahal and Jalil have been held while awaiting trial, said he would base his defense on the fact that his clients were "soldiers" and, as such, should be treated as "prisoners of war."

The influential Madrid newspaper El Pais today reported the possibility that both detainees, if found guilty and sentenced, could be transferred to a Lebanese prison to serve their terms. Such a move, it was suggested, would be a compromise that could aid the negotiating process in Beirut.

Officials did not comment on the newspaper's report. They noted that while there was "permament communication" with the U.S. Embassy in Madrid, no pressure had been brought on how to deal with demands for the release of the two Shiites.