Libyan city is back under the control of the UN-recognised government after being used as a base to launch attacks on the capital Tripoli.