Clashes occurred in western Libya since 14 October 2016, when a coup d'état attempt was conducted by the former head of the National Salvation Government (GNS), Khalifa al-Ghawil, against Prime Minister Fayez al-Sarraj, the head of Libya's Government of National Accord (GNA). This evolved into fighting between the GNA and GNS for control of Tripoli and parts of western Libya, while pro-GNA militias also attacked other militias for control of the region.

Background

Following the First Libyan Civil War and the fall of the Libyan Arab Jamahiriya, the country had been in a state of discord and infighting. In 2014 the General National Congress was dissolved and new elections were called for the newly formed House of Representatives; following the election, Abdullah al-Thani was appointed as new prime minister.

In the meantime, Field Marshal Khalifa Haftar launched Operation Dignity, a massive military operation against Islamic militias. This caused an escalation of violence, resulting in the beginning of the Second Libyan Civil War. Because of the constant violence, the Government and the House of Representatives were forced to abandon Tripoli and relocate to Tobruk.

On 6 September 2014, a faction of former Islamists MPs took control of Tripoli and re-established the General National Congress. The New GNC appointed a National Salvation Government (NSG) and elected Khalifa al-Ghawil as prime minister. Since then, two rival government existed in Libya, one based in Tripoli and the other in Tobruk.

On 5 April 2016, the United Nations brokered an agreement to create a Government of National Accord (GNA), with Fayez al-Sarraj as prime minister: the proposal was rejected by both factions. In the following weeks GNA and allied militias took control of Tripoli and terminated NSG, also dissolving the New GNC and establishing the Presidential Council and the High Council of State (HCS).

The Tobruk government and its militia in the east led by Marshal Khalifa Haftar opposed the GNA. His forces had taken over the four key oil ports of Essidra, Ra's Lanuf, Brega and Al-Zueitina, but were cooperating with the GNA to permit oil exports.

On 31 August 2016, a 94-member rival to the HCS was proclaimed in Benghazi and its members offered to join the official HCS. On 10 October, the HCS's headquarters was attacked by unknown gunmen.

Coup d'état attempts Late on 14 October, al-Ghawil proclaimed the reinstatement of the former GNS, having taken over the offices of a key consultative body of the GNA at the Rixos Hotel, a complex of administrative buildings and a television station, with GNA forces pulling back in the late afternoon without violence. The GNS supporters said the GNA was "void" and that they had replaced it. Al-Ghawil also declared all members of the GNA "suspended from their duties." He also said: "The presidential council was given chances one after another to form the government, but it has failed...and has become an illegal executive authority." He called for a new administration to be formed by the former Tripoli and Tobruk governments. He further claimed that all institutions including banks, the judiciary, and local authorities were under their jurisdiction.

The following day, the GNS-supporting militiamen in pickup trucks with mounted machine guns remained in place, though Tripoli was calm after the events. Meanwhile, the GNA posted images on social media showing its Presidential Council and ministers holding a meeting in the main offices of parliament in a different part of Tripoli, though earlier reports suggested they may have been in neighboring Tunisia. The GNA then reacted by threatening to arrest "those politicians who... attempt to create parallel institutions and destabilise the capital," while also condemning "efforts to sabotage the political agreement" and denounced the seizure of the Council of State building by an "armed group."

On 16 October, forces loyal to al-Ghawil sent reinforcements to protect the parliament building. They also seized the Government Palace. On the same day, fighting near a refugee camp in the area of Fallah, near the road to the airport, led to the death of at least one woman. Six other people, including a child, were wounded. The Presidential Guard then also pledged allegiance to the GNS. It was reported by Jeune Afrique that the Presidential Guard dropped the GNA because of unpaid wages.

On 17 October, Ghwail claimed on television that the GNS had fully taken control of the capital. Clashes between Ghawil forces and policemen also occurred.

Further clashes

2016–17 On 28 November, representatives from House of Representatives (HoR) and GNC met in Tripoli to reach a deal and form a new government. On 1 December, Omar al-Hassi announced the formation of the High Council of Revolution, a parallel executive body.

Clashes occurred in Tripoli between the two sides from 1 to 2 December after pro-GNA militias attacked pro-GNS militias. 8 people were killed, including civilians, while more than 20 were wounded. Clashes were reported in many areas including Rixos hotel. A ceasefire agreement was reached the next day. The agreement required two armed groups in the Al-Nasr Park in Bab Benghashir areas to leave and hand the location to the Presidential Security Personnel of the Salvation Government before being transferred to the control of Youth and Sports Ministry. Clashes erupted again between Tripoli and Misratan militias on 4 December due to disputes over the control of territories.

GNS claimed it had seized the buildings of ministries of defence, labour and the "martyrs and the wounded" on 12 January 2017. A GNA spokesman later confirmed that the militias had tried to seize the buildings, however stated they were unsuccessful.

On 2 February 2017, clashes in western Tripoli district of Janzour near Bridge 17 broke out between Wirshefana militias and the Fursan Janzour brigade, with some sources suggesting up five people have been killed and 15 wounded.

On 8 February, clashes occurred in Abu Sleem as well as Saladin district between Abu Sleem Central Security Force, which supports the GNA and the Salah al-Burki Brigade, which supports of the GNS and consists mostly of Misratans. Some days prior it had arrested men purportedly belonging to the Libyan National Guard (LNG), which is also loyal to GNS of Ghweill. On 10 February, the newly created LNG entered Tripoli.

On 24 February, 8 people were killed during fighting between GNA and GNS forces in Tripoli's Abu Sleem district. Three of the dead were civilians who were killed when a missile hit Hamza Street. During nighttime on 13 March, clashes erupted between armed residents of Gurji and Hay Andalus backed by Tripoli Revolutionaries’ Brigade against Misratan and Amazigh militias.

The fighting spread to other areas of Tripoli on 14 March. Tripoli Revolutionaries’ Brigade attacked and besieged the Rixos compound, the location of GNC and Salvation Government, in Bab Bin Ghashir district during the night after a night of fighting on 15 May. The Pro-GNA forces had recaptured the Guest Palace complex as well as the Rixos hotel. The office of the Al-Nabaa channel loyal to GNC was attacked by unknown gunmen and was burnt down in the clashes. The channel was taken off-air while Khalifa Al-Ghawil was also reported by one of his aides to have been injured in the clashes. A ceasefire agreement was later signed by GNA members, elders and councils of Misrata and Tripoli, Tripoli High Council for reconciliation and a number of brigades’ commanders from Tripoli, Souq al Jum'aa and Misrata during a meeting at Abu Sittal Naval Base. The agreement called for withdrawal of all armed groups from Tripoli in 30 days. The ceasefire was however rejected by both Tripoli Revolutionaries' Brigade as well as the Abu Sleem Central Security Force on 16 March while renewed clashes were reported.

On 9 May, at least one person was killed and a number of others injured in Tripoli old town and around Musheer marketplace when two rival local militias clashed.

As of 26 May, at least 52 UN-backed Government of National Accord (GNA) fighters had been killed (at least 17 executed) and many others wounded in heavy clashes with rival militiamen in Abu Salim, Hai Damascus, Al-Eddine, Hai Akhwakh, Salahedeen and Qasr Bin Ghashir districts, according to a GNA official. The Tripoli Revolutionaries Brigade attacked the Hadba prison and clashed with the Security Department Forces led by Khaled Al-Sharif, killing at least two guards. The Al-Sharif-led forces pulled out. TRB seized the prison and demolished Al-Sharif's house. The Presidency Council-backed Ministry of Interior meanwhile stated that all prisoners had been transferred, including Saadi Qaddafi and former intelligence chief Abdullah Senussi.

On 28 May, the 7th Brigade of the Presidential Guard (Al-Kani brigade) from Tarhuna, took over the Tripoli International Airport as a neutral side after Misratan militias loyal to Khalifa Ghwell withdrew from there following two days of heavy clashes. TRB's commander Haithem Tajouri rejected the takeover and demanded Kani Brigade to withdraw immediately. Presidential Guard under command of GNA took control of the airport from Kani militia later. This marked the first time in three years that the airport had been controlled by a force loyal to the internationally recognized government. By the next day, the city of Tripoli was fully under control of pro-GNA forces, with all pro-GNC forces withdrawing as a result of clashes with pro-GNA forces.

On 4 July, a family of five were reported to have been killed and at least 32 injured in the early afternoon at a beach near Mitiga airport, when a rocket-propelled grenade exploded beside them. Later on that day, Tripoli Revolutionaries’ Brigade had been sent to the area and the airport was forced to close.

On 7 July 2017, three Libyan National Army (LNA) soldiers belonging to the GNA's Brigade 103, along with two of their friends were found shot dead in Wadi Rabie, near Tripoli International Airport.

On 9 July, heavy clashes reportedly erupted between the National Guard and pro-Serraj forces in Castelverde. A day later, it was reported that GNA-allied militias which came out from Tripoli to block the advance of the pro-GNC forces had withdrawn back to their positions in Tripoli due to unclear reasons.

On 11 July, the Tripoli Revolutionaries’ Brigade (TRB) claimed to be in complete control of Garabulli after three days of fighting which forced more than 85 percent of the town's population to flee. A Tripoli hospital reported four deaths during the fighting, including two foreign workers and 21 injuries. TRB had advanced on the town to block a push on by forces loyal to Khalifa Ghwell. These forces included members of Sala Badi's Samoud militia as well as Benghazi Defense Brigades. Hospitals in Tripoli recorded 4 deaths and 21 injuries, while casualties among the attacking forces were unknown.

Three people, including a civilian, were killed in clashes between Tripoli Revolutionaries Brigade on 1 October and Nawasi Brigade in Tripoli's Gurji district. The TRB forces were reportedly sent to clear Gurji's Massara area from a Nawasi unit led by an extended family, Alwad Radiah, and reportedly succeeded. One of the Alwad Radiah leaders was killed while the third body was unidentified. The fighting had been triggered by Nawasi's attempt to take over TRB headquarters in Shara al-Shatt, though there were no serious clashes except shooting in the air.

TRB forces supported by Brigade 301 and Kani Brigade, attacked Gaddafi loyalists on 4 October 2017. According to TRB sources, they attacked the Gaddafi loyalists in Qasir Ben Ghashir, Sayah and Wadi Rabea; taking control of all their camps while two men from Brigade 301 were killed. The loyalists later fled to Wershiffana. Gaddafi loyalists on Facebook identified the group as "Popular Front for Liberation of Libya".