(CNN) Senegalese troops have entered neighboring Gambia amid a growing crisis as the West African nation's longtime ruler Yahya Jammeh refuses to step down.

Jammeh, who took power in a 1994 military coup, suffered a surprise election defeat in December to Adama Barrow, who won 45% of the vote. Jammeh originally conceded the presidency, but then announced his "total rejection of the election results."

Barrow was sworn in Thursday at Gambia's embassy in Senegal, as the United Nations Security Council backed an effort by West African states to remove Jammeh.

The UN called on "all stakeholders, within and outside the Gambia, to exercise restraint, respect the rule of law and ensure the peaceful transfer of power."

Troops from several West African countries had been poised to intervene if Jammeh insisted on staying in the post beyond a midnight deadline.

Senegal, Ghana, Togo and Mali are among the countries which contributed to the military effort, while the Nigerian Air Force said 200 of its troops would join forces from the Economic Community of West African States (ECOWAS).

"The deployment is also to forestall hostilities or breakdown of law and order that may result from the current political impasse in Gambia," a Nigerian statement said.

Leader-in-waiting

Barrow has been waiting in Senegal -- which surrounds Gambia -- for the handover of power. In his first speech as leader, he hailed the "victory of the Gambian nation."

This is a victory of the Gambian nation. Our national flag will fly high among those of the most democratic nations of the world. #Gambia pic.twitter.com/QRGZg1gzbs — Adama Barrow (@adama_barrow) January 19, 2017

"Our national flag will now fly high," he said. "Violence is finished forever from the life of the Gambians. There is no loser in this election. We promise to unify our people. Today most Gambians are united in order to give Gambia a new start. Today I am the President of all Gambians."

He pledged to "respect the rule of law and fundamental freedoms" and promised "significant democratic reform."

JUST WATCHED 'A situation of contested legitimacy' in Gambia Replay More Videos ... MUST WATCH 'A situation of contested legitimacy' in Gambia 05:02

And he called on the country's military to remain loyal: "I command all members of the armed forces to remain in their barracks. Those found wanting, or in possession of firearms, without my order, shall be considered rebels."

Barrow's spokesman, Halifa Sallah, said the military "will have to decide which side they are on."

Facing uncertainty at home, people in Banjul, Gambia, head to a ferry this week bound for Senegal.

Seeking safety

Tens of thousands of people have fled their homes in Gambia fearing political violence, as Save the Children warned of the danger of a humanitarian emergency.

"These children are largely fleeing to parts of both Gambia and Senegal where public services such as health facilities and schools are already under a great deal of strain," said Bonzi Mathuri, Save the Children's Senegal country director.

Senegalese soldiers are entering the country to remove Jammeh.

On Tuesday, Jammeh declared a state of emergency, claiming "a situation exists which, if it is allowed to continue, may lead to a state of public emergency," and said he had filed an application with Gambia's Supreme Court to prevent Barrow being sworn in

Hundreds of tourists have been pouring out of Gambia as the risk of violence grows and the US and UK issued warnings to citizens to consider leaving the country.

In a statement on its website, tour operator Thomas Cook said it was "working hard to get our UK customers home" and it expected to fly about 3,500 vacationers out of Gambia by the end of Friday.

British tourist Sara Wilkins, 44, told CNN she and her husband arrived in Gambia nearly a week ago and noticed a lot of military on the streets. She said they had not been able to leave their hotel in recent days.

Tourists gather at the Banjul airport Wednesday as tour operators send in extra flights for evacuation.

Wilkins said she had witnessed "manic" scenes at the airport and at the hotel, where "everyone was panicking and crying."

On her return flight home, she said she sat next to a Gambian man who cried throughout the journey having failed to get his wife and 3-month-old baby out of the country.

The UK warned that "potential for military intervention and civil disturbance is high and could result in Banjul International Airport being closed on short notice."