The United States has been involved in secret talks with Arab and other intermediaries for more than a year to gain the release of American hostages in Lebanon, Arab and other diplomatic sources say.

U.S. officials refused yesterday to discuss the details of past and present diplomatic efforts to free the six Americans still captive and the Rev. Benjamin Weir, who was released last Saturday.

But the Reagan administration has been counting on the intervention of Syrian President Hafez Assad to persuade the Shiite captors of the Americans to free them, according to diplomatic sources. Assad has agreed to help but has also indicated his own frustrations in gaining the captors' cooperation.

Furthermore, various other Arab and European channels have also been asked to contact the captors, as well as their Iranian backers.

At one point, there was an attempt to persuade the Shiites to release the Americans in return for a pledge that the 17 convicted terrorists in Kuwait would subsequently be quietly freed. The U.S. government was not involved directly in those negotiations but was aware of them, according to Arab sources familiar with the talks.

The negotiations were difficult because the Americans were held by more than one group. Furthermore, the captors, some of whom are relatives of the Shiite terrorists being held in Kuwait, could not agree among themselves on the terms for the hostages' release.

The 17 terrorists were among 25 persons tried and convicted -- eight in absentia -- in March 1984 for their roles in seven bombings around Kuwait City the previous December that killed six people and wounded more than 80 others. Most of the convicted terrorists are Iraqi Shiites belonging to the Iranian-backed fundamentalist group known as Dawa.

Most of the deaths and injuries occurred at the U.S. Embassy, where a terrorist drove a truck loaded with explosives into the compound and detonated it. The French Embassy was also bombed.

Three of the 17 captured terrorists were sentenced to death by hanging and the others received prison terms ranging from five years to life. But the ruling emir, Sheik Jaber Ahmed Sabah, has not yet formally ratified the sentences and the executions have not been carried out.

Circumstantial evidence strongly suggests that the spate of kidnapings of Americans in Beirut was motivated by the trial of the 17 terrorists in Kuwait and the desire of their relatives in Lebanon to gain their freedom.

One of the captors in Lebanon is reportedly from the Mussavi family, which is extremely active in the Shiite fundamentalist movement in Lebanon and has close ties to Iran.

The swap plan failed to materialize, partly because the Shiite captors insisted their brethren in Kuwait be freed first and partly because Kuwait toughened its posture after a Kuwaiti airliner was hijacked to Tehran by other Shiite terrorists last December, according to these sources.

Those hijackers, who killed two U.S. Agency for International Development officials, also demanded that Kuwait set free the 17 convicted terrorists, but the Kuwaiti government refused to do so. On Dec. 9, the Iranians stormed the plane and ended the hijacking.

At the time of the Kuwaiti plane hijacking, officials in Kuwait City privately said the incident had been counterproductive to the hijackers' objectives since the quiet release of the terrorists had been under consideration in government circles.

Since that time, Kuwait has become steadily more defiant and uncompromising toward any consideration of their release despite repeated terrorist attempts to cow the ruling Sabah family into freeing them.

On May 25, a suicide bomber drove a car into Sheikh Jaber's motorcade, killing five persons, including himself, but inflicting only minor injuries on the sheikh. Then on July 11, bombs exploded in two popular cafes in Kuwait City, killing nine persons and injuring 56 others.

Both incidents were believed to be attempts by friends of the 17 convicted terrorists to put pressure on the Kuwaiti government to release them.

The first of the Americans to be seized, William Buckley, a U.S. Embassy political officer, was taken from a Beirut street on March 16, 1984, 11 days before the formal sentencing of the 17 terrorists in Kuwait. Weir was abducted May 8 and the others over the ensuing months.