TRIPOLI, Libya — Libya and the United States settled all outstanding lawsuits by American victims of terrorism on Thursday, clearing the way for the full restoration of diplomatic relations.

There were 26 pending lawsuits filed by American citizens against Libya for the 1988 bombing of Pan Am Flight 103 over Lockerbie, Scotland, and other attacks, said a senior Libyan government official, who spoke on condition of anonymity because the details of the deal had not been publicly announced.

The official said there were also three outstanding lawsuits filed by Libyan citizens for U.S. airstrikes on Tripoli and Benghazi in 1986 that Libyans say killed 41 people, including leader Moammar Gadhafi's adopted daughter.

State Department spokesman Robert Wood confirmed the deal.

"The agreement is designed to provide rapid recovery of fair compensation for American nationals with terrorism-related claims against Libya," he said in a statement. "It will also address Libyan claims arising from previous U.S. military actions. The agreement is being pursued on a purely humanitarian basis and does not constitute an admission of fault by either party."

The settlement completes a nearly five-year effort to rebuild ties between the two countries.

A joint U.S.-Libya statement issued later Thursday in Tripoli said that "both parties welcomed the establishment of a process to provide fair compensation for their respective nationals, and thereby turn their focus to the future of their bilateral relationship."

The agreement will be followed by a U.S. upgrading of relations with Libya including the opening of an embassy in Tripoli, the confirmation of a U.S. ambassador and a visit by Secretary of State Condoleezza Rice before the end of the year. It will also allow direct U.S. aid. The agreement also gives immunity to the Libyan government from any further terror-related lawsuits, the Libyan government official said.

The mother of one of the Lockerbie victims called the settlement a "triumph for terrorism."

The U.S. had no diplomatic relations with Libya from 1980 until late 2003, when Gadhafi pledged to abandon his weapons of mass destruction programs, stop exporting terrorism and compensate the families of victims of the Lockerbie bombing and other attacks.

After that, the nation that once was a global pariah was given a reprieve from U.N., U.S. and European sanctions, removed from the State Department's list of state sponsors of terrorism and allowed a seat on the U.N. Security Council.

The last hurdle was over compensation for Americans harmed in Libyan-sponsored attacks, including the Lockerbie attack and the 1986 bombing of La Belle discotheque in Berlin, which killed two American soldiers. The disco attack prompted former President Reagan to order the 1986 airstrikes on Libya.

Libya has paid the 268 families involved in the Pan Am settlement $8 million each, but was withholding an additional $2 million it owed each of them because of a dispute over U.S. obligations in return.

The main Libyan lawsuit was filed by 45 families of those killed in the 1986 airstrikes. There are two other cases pending related to other incidents.

Many of the relatives of victims from the Lockerbie bombing have opposed any deal on compensation, saying Libya should be held fully accountable in all the attacks pinned to it.

"They allow this horrible terrorist who murdered my daughter and all these other people to triumph. This is a triumph for terrorism," said Susan Cohen, the mother of Lockerbie bombing victim Theodora Cohen.

"All this does, it says 'we swept the families away. We pretend that Gadhafi never blew up an American plane," she said.

Under the agreement, a fund will be set up to compensate the American and Libyan claimants, Libyan and U.S. officials said. International institutions and foreign companies operating in Libya — including some American firms — will contribute to the fund.

Sen. Joseph Biden, D-Del., chairman of the Senate Foreign Relations Committee, said in a statement that the agreement provides enough money to make sure every American claimant in other cases involving Libyan terrorism will receive compensation comparable to settlements reached for the Pan Am 103 attack and the 1986 bombing of the La Belle discotheque in Berlin, which killed two American soldiers.

"The agreement provides some justice and closure for the victims of Libyan terrorism and their families," Biden said. "But it is small consolation and will not bring back the lives that have been lost, nor undo the suffering endured by survivors."

The top U.S. diplomat for the Middle East, David Welch, signed the deal with Ahmed al-Fatouri, head of America affairs in Libya's Foreign Ministry, in a ceremony before reporters and members of both delegations.

"We went through a long path of negotiations until we reached this agreement," al-Fatouri said just before the signing. "It opens new horizons for relations based on mutual respect. ... The agreement turns the page on the negative past forever."

Welch called the deal a "historic agreement" and said he delivered a letter from President Bush to Gadhafi.