TRIPOLI (Reuters) - Libya closed the only functioning airport in the capital Tripoli after rockets were fired in its direction, the airport said on Wednesday, only five days after flights had resumed following a previous shutdown forced by fighting among rival armed groups.

Nobody was hurt by the rocket fire late on Tuesday which missed all aircraft, but the violence undermined a fragile truce between the groups in Tripoli which the United Nations brokered last week.

Some groups based outside Tripoli have attacked rival factions based in the capital to gain access to public funds and businesses linked to militias, a recurring theme in the OPEC oil producer since the toppling of Muammar Gaddafi in 2011.

Matiga airport, a former air base used for commercial flights since the main airport was heavily damaged in 2014 by militia fighting, said it had moved planes and crews to Misrata, a city east of Tripoli.

“All flights will be from and to Misrata International Airport,” Matiga airport said on Facebook.

U.N. envoy Ghassan Salame said a new security arrangement would be implemented in the next few days despite the incident. “We know exactly who is bombing Matiga airport ... once four days ago and then last night ... I will name him next time,” Salame told reporters.

He gave no details on the planned security deal which is likely to add more groups to the public payroll to win their loyalty, a strategy that has failed in the past as it only attracted other players.

Rival groups fought for several days in Tripoli until last week but the clashes had been mainly in the south of the city, whereas Matiga airport lies in an eastern suburb.

Salame has been pursuing a plan, backed by France, to hold elections this year though the House of Representatives based in the east and allied to a rival administration has failed to approve the constitutional framework and legislation so far.

Tripoli-based Prime Minister Fayez Seraj said conditions were too unstable to hold a vote. “You cannot vote with instability in the streets ... it is necessary that everyone accepts the result of the ballot,” he told the Italian daily Corriere della Sera.