PORT OF SPAIN, TRINIDAD, JULY 30 -- An agreement to resolve the hostage crisis that has gripped this Caribbean island since Friday wavered in the balance tonight following a day of fierce gun battles and on-again, off-again bargaining between negotiators for the government and Moslem rebels.

Government officials and a mediator had said this afternoon that they expected an imminent announcement of a settlement that would include freedom for the 41 hostages held by the rebels, including Prime Minister Arthur Robinson and other top government officials.

But this evening, government spokesman Gregory Shaw read a statement that said: "Up to this time . . . the government has not agreed to the demands of the group that has been holding the prime minister and his colleagues and other persons at gunpoint since they burst into Parliament Friday evening."

He added that the government and military were "extremely concerned" about the safety of the hostages. The rebels, members of a radical black Moslem group with links to Libya, are believed to be armed with AK-47 assault rifles, pistols and grenades and claimed to have wired Robinson to explosives rigged to detonate if troops try to storm the Parliament building.

{As midnight approached, however, there were indications that the deal might be back on as Robinson telephoned government officials from inside the Parliament building to say that he had reached accord with the gunmen "after very difficult bargaining," the Associated Press reported.

{Robinson said also that he had instructed Col. Joe Theodore, head of the Trinidad and Tobago Defense Force, to "make necessary arrangements for the evacuation {of hostages and rebels} as soon as possible," but it was unclear if Robinson was speaking freely or under continued duress.

{Justice Minister Selwyn Richardson, also speaking by phone from the rebel-controlled Parliament building, told officials outside that the accord called for Robinson to resign at once and for new national elections within 90 days, contingent "upon the safe return of all members of Parliament" now held hostage, the AP said. It was not immediately clear how Trinidadian authorities outside the building would respond to the phone messages.}

Sixteen hostages were being held at the Parliament building, government spokesman Shaw said. Eight of them, including Robinson, are government ministers; six are other members of the legislature; one is a former ambassador to Britain; and one is a high-ranking civil servant. The other 25 hostages were being held at the facilities of Trinidad and Tobago television. Most are reportedly television employees.

Maj. David Williams of the Trinidad and Tobago Defense Force said the initial agreement, as outlined, would have provided freedom for the hostages in return for safe passage for the rebels, who would be allowed to return to their headquarters on the outskirts of this capital. He also said that Robinson had told an Anglican priest who is mediating the negotiations that he would not leave the Parliament building, or Red House, until all the hostages were safe.

A government source said that a major stumbling block in negotiations earlier today was whether the rebels would be allowed to keep their weapons.

An estimated 120 rebels of the Jamaat Muslimeen launched the attack on the government about 5:30 p.m. Friday, when they blew up police headquarters and took control of the state-run television headquarters and the Parliament building.

The Sunday Express, an independent newspaper, reported that the fighting has caused 314 injuries, 169 of them serious enough to require surgery. Local reports have mentioned from 22 to more than 100 deaths. Figures could not be confirmed.

Shaw, the government spokesman, confirmed that Robinson has been shot in both feet, apparently on Friday when he initially refused to cooperate with the rebels. Shaw said that Robinson and other government officials who were hurt in the attack on the Parliament building were thought to be in stable condition.

Today, as the two groups of rebels continued to hold hostages at Red House and at the television station, fighting took place at both places despite a cease-fire declared Saturday. The television headquarters was the scene of intense fighting for nearly an hour this morning, when a group of rebels tried unsuccessfully to burst through the government lines. They encountered troops who had surrounded the area, and the two sides exchanged fire with automatic weapons, mortars and rocket-propelled grenades, witnesses said. "We won the firefight," said Williams, the armed forces spokesman.

There had been reports over the weekend that military leaders were balking at the idea of an agreement that would include amnesty for the rebels, but Williams and Shaw both denied that today.

The rebels, members of a radical group with a membership estimated at 250 to 500, have claimed that Robinson's government is immoral and riddled with corruption. In addition, the group has battled the government in court over plans to expand its facilities at a complex near the capital.

The leader of the group, Yasin Abu Bakr, is a former policeman who has been imprisoned at least once in the course of the group's disputes with the government, and police have raided the group's complex in the past in search of weapons.

Last week, just days before the start of the coup attempt, a court ruled against Abu Bakr's group's bid to expand its facilities in the Mucarapo area near Port of Spain. News services have reported that residents have cited the dispute as the group's motivation for attempting the coup.

In an interview several years ago with The Express, Abu Bakr acknowledged traveling to Libya and has called Libyan leader Moammar Gadhafi "our friend."

{In Washington, State Department spokesman Richard Boucher called the attempted coup an example of Libyan involvement with extremist groups worldwide but said Washington had no plans for military intervention. White House spokesman Stephen Hart said there were no reports of any harm to the approximately 6,000 Americans in Trinidad and Tobago.}

Trinidad and Tobago, with a population of about 1.3 million, is ethnically and politically divided between blacks and East Indians. The rebel group has never been a major force in the islands' politics.