structural:reformatting
Conflict with the US and its allies: 1981–1986

The early 80s saw economic trouble in Libya; from 1982 to 1986, annual oil revenues dropped from $21 to $5.4 billion. Focusing on irrigation projects, 1983 saw construction start on Libya's largest and most expensive infrastructure project, the Great Man-Made River; although designed to be finished by the end of the decade, it remained incomplete at the start of the 21st century. Military spending increased, while other administrative budgets were cut. Foreign debt rose, and austerity measures were introduced to promote self-reliance; in 1985 there was a mass deportation of foreign workers, mostly Egyptian and Tunisian. Domestic threats continued to plague Gaddafi; in May 1984, his Bab al-Azizia home was unsuccessfully attacked by a militia—linked to the NFSL or Muslim Brotherhood—and in the aftermath 5,000 dissidents were arrested. In spring 1985, members of the military tried to assassinate Gaddafi twice. The first was a plot by conservative officers to assassinate him at a villa on the outskirts of Tripoli; the second was an assault on his convoy. In November 1985, Colonel Hassan Ishkal, the third most powerful man in Libya, head of the military region of Sirte, died in a suspicious car accident. Ishkal's death was attributed to Jalloud, Khalifa Hunaysh or Gaddafi.

Libya had long supported the FROLINAT militia in neighbouring Chad, but FROLINAT became divided over its ties to Libya in 1976. In January 1978, the anti-Libya faction within FROLINAT, led by Hissène Habré, switched sides and allied with Chadian President Félix Malloum. Meanwhile, the pro-Libya faction within FROLINAT, led by Goukouni Oueddei, renamed itself People's Armed Forces (FAP). In December 1980, Gaddafi reinvaded Chad at the request of the FAP-controlled GUNT government to aid in the civil war; in January 1981, Gaddafi suggested a political merger. The Organisation of African Unity (OAU) rejected this and called for a Libyan withdrawal, which came in November 1981. The civil war resumed, and Libya sent troops back in.

In 1982, the GUNT government was overthrown by Habré's forces and Oueddei fled to Libya, where Gaddafi provided him with arms to continue to guerrilla war against Habré. In November 1984, Gaddafi met with French President François Mitterrand; both agreed to withdraw from Chad. Oueddei broke with Gaddafi in 1985 due to the former's intentions to negotiate a truce with Habré. Consequently, he was placed under house arrest by Gaddafi and allegedly arrested by Libyan police and shot in the stomach. Oueddei survived the shooting and fled to Algeria, but continued to claim he and Gaddafi enjoyed a good relationship. When Gaddafi ordered the remnant of GUNT to attack Habré in February 1986 in violation of his agreement with Mitterrand, France launched Operation Épervier, which escalated into the Toyota War. Libya suffered a humiliating defeat as it was completely expelled from Chad and its commander Khalifa Haftar captured, along with 600-700 Libyan soldiers. Gaddafi disavowed Haftar and the other prisoners; one possible contributing factor to this repudiation may have been that Gaddafi had signed an agreement to withdraw Libyan forces, and Haftar's operations had been in violation of this. An embittered Haftar then joined the anti-Gaddafi National Front for the Salvation of Libya, became a CIA asset, and was given refuge in the US.

Many African nations were tired of Libya's interference in their affairs; by 1980, nine African states had severed diplomatic relations, while in 1982 the OAU cancelled its scheduled conference in Tripoli to prevent Gaddafi gaining chairmanship. Some African states, such as Jerry Rawlings 's Ghana and Thomas Sankara 's Burkina Faso, had warm relations with Libya during the 1980s.

Proposing political unity with Morocco, in August 1984, Gaddafi and Moroccan monarch Hassan II signed the Oujda Treaty, forming the Arab–African Union; such a union was considered surprising due to the political differences and longstanding enmity that existed between the two. In a sign of warming relations, Gaddafi promised to stop funding the Polisario Front and Hassan II extradited former RCC member Umar Muhayshi to Libya, where he was immediately killed. But relations deteriorated, particularly due to Morocco's friendship with the US and Israel; in August 1986, Hassan abolished the union. Angered by the snub, Gaddafi plotted with Abu Nidal to assassinate Hassan in 1987, but the plot was aborted.

In 1981, the new US president, Ronald Reagan, pursued a hardline approach to Libya, viewing it as a puppet regime of the Soviet Union. Gaddafi played up his commercial relationship with the Soviets, revisiting Moscow in 1981 and 1985, and threatening to join the Warsaw Pact. The Soviets were nevertheless cautious of Gaddafi, seeing him as an unpredictable extremist. In August 1981, the US staged military exercises in the Gulf of Sirte – an area which Libya claimed. The US shot down two Libyan Su-22 planes which were on an intercept course. Closing down Libya's embassy in Washington, Reagan advised US companies operating in Libya to reduce Americans stationed there. In December 1981, the White House claimed Gaddafi had dispatched a hit squad to assassinate Reagan, allegedly led by Carlos the Jackal, who had been living in Libya under Gaddafi's protection after the 1975 OPEC siege. Secretary of State Alexander Haig, Defense Secretary Caspar Weinberger, Counselor to the President Edwin Meese, chief of staff James Baker, and deputy chief of staff Michael Deaver were considered potential targets and given special security. US ambassador to Italy Maxwell M. Rabb, who was Jewish, was urgently recalled due to threats against his life. Gaddafi denied the allegations. Gaddafi was accused of having ties to the Lebanese Armed Revolutionary Factions, which had murdered US military attaché Charles R. Ray and Israeli diplomat Yacov Barsimantov in Paris. In March 1982, the US implemented an embargo of Libyan oil, and in January 1986 ordered all US companies to cease operating in the country, although several hundred workers remained when the Libyan government doubled their pay. In spring 1986, the US Navy again performed exercises in the Gulf of Sirte; the Libyan military retaliated, but failed as the US sank Libyan ships. Diplomatic relations also broke down with the UK, after Libyan diplomats were accused in the killing of Yvonne Fletcher, a British policewoman stationed outside their London embassy, in April 1984.

In 1980, Gaddafi hired former CIA agent Edwin P. Wilson, living in Libya as a fugitive from US justice, to plot the murder of an anti-Gaddafi Libyan graduate student at Colorado State University named Faisal Zagallai. Zagallai was shot in the head in October 1980, in Fort Collins, Colorado by a former Green Beret and associate of Wilson named Eugene Tafoya. Zagallai survived the attack and Tafoya was convicted of third-degree assault and conspiracy to commit assault. Wilson was lured back to the US and sentenced to 32 years due to his ties to Gaddafi. In 1984, Gaddafi publicly executed Al-Sadek Hamed Al-Shuwehdy, an aeronautical engineer studying in the US.

After the US accused Libya of orchestrating the 1986 Berlin discotheque bombing, in which two US soldiers died, Reagan decided to retaliate. The CIA was critical of the move, believing Syria was a greater threat and that an attack would strengthen Gaddafi's reputation; however, Libya was recognized as a "soft target". Reagan was supported by the UK, but opposed by other European allies, who argued it contravened international law. In Operation El Dorado Canyon, orchestrated on 15 April 1986, US military planes launched air-strikes, bombing military installations, killing around 100 Libyans, including civilians. One target had been Gaddafi's home. Himself unharmed, two of Gaddafi's sons were injured, and he claimed his adopted daughter Hanna was killed, although her existence has since been questioned. Gaddafi retreated to the desert to meditate. There were sporadic clashes between Gaddafists and army officers who wanted to overthrow the government. Although the US was condemned internationally, Reagan received a popularity boost at home. Publicly lambasting US imperialism, Gaddafi's reputation as an anti-imperialist was strengthened domestically and across the Arab world, and, in June 1986, he ordered the names of the month to be changed in Libya.