Leaders of Libya's new unity government have arrived in the capital, Tripoli, by boat in an attempt to take control.
Over recent days, Tripoli's airspace has been intermittently closed to stop the Presidency Council, which has been based in Tunisia, from arriving by air.
Libya's UN envoy called for "a peaceful and orderly handover".
But hardliners in the coalition that controls Tripoli are opposed to the UN-brokered deal aimed at reconciling a nation split by five years of conflict.
In a televised address, the head of the Tripoli authorities, Khalifa Ghweil, said he regarded the politicians as interlopers and said they were not welcome.
He urged "the illegitimate outsiders to surrender and be safe in our custody or to return to where they came from".
Late on Wednesday, journalists from a television channel supportive of authorities in Tripoli said it was taken off air after gunmen stormed its offices. It was not clear to whom the gunmen were affiliated.
Libya has been in chaos since the 2011 overthrow of long-serving ruler Muammar Gaddafi by Nato-backed forces.
From 2014 it has had two competing administrations, one in Tripoli backed by powerful militias and the other about 1,000km (620 miles) away in the port city of Tobruk.
In the first hours after the politicians' arrival at the navy base, militias on armed pick-up trucks were seen securing most parts of the capital. But by early evening, gunfire from rival groups started ringing out.
It is not clear what their plan is, but things are now tense.
Many of the brigades in western Libya have fallen in line behind the Presidency Council. However, the reality is that these are the very same militias who led and facilitated the existence of the rival authorities in Tripoli since 2014.
Their continued prominent role means their status will not change - it simply puts any new government at their mercy. Ultimately they are Libya's rulers.
Militia allegiances often shift out of convenience and with the need to survive.
Key to any progress and long-term transformation of Libya will be having a government that can control these brigades.
In December, some rival lawmakers signed up to the UN agreement to form a unity government, but the deal has not yet been backed by all the country's many militia brigades that formed after the uprising.
The deal saw the formation of a nine-member Presidency Council, which includes the unity Prime Minister Fayez Sarraj who arrived with some of his deputies at a naval base in Tripoli on Wednesday.
Mr Sarraj said it was time to turn a new page and reconcile, saying he intended to build state institutions and implement a ceasefire.
"Revenge, alienation, antipathy, and hatred don't build a state," the AP news agency quoted him as saying.
The BBC's North Africa correspondent Rana Jawad says the Presidency Council has faced numerous challenges since its formation, chief of which has been its inability to establish a presence in Tripoli.
UN envoy Martin Kobler said the politicians' arrival in Tripoli - after at least two failed attempts to fly in - marked "an important step in Libya's democratic transition and path to peace, security and prosperity".
In a statement, he "urged all public bodies, including official financial institutions, to facilitate an immediate, orderly and peaceful handover of power".
US Secretary of State John Kerry said it was "not the time for obstructionists to hold back progress".
But our reporter says it is not clear how Mr Sarraj and his colleagues will be able to take over state institutions in Tripoli, given the stiff rivalry they face and the fact that members of his proposed cabinet are based all over the country.
The political and security vacuum in Libya has helped the so-called Islamic State group to establish a foothold in the north African country, carrying out attacks on cities and against oil installations.