By Dionne Searcey and Jaime Yaya Barry

New York Times News Service

DAKAR, Senegal — The political standoff in Gambia intensified on Thursday as foreign troops crossed the border with orders to dislodge a repressive leader who has refused to step down after losing a presidential election last month.

Gambia’s erratic leader, Yahya Jammeh, seized power in a coup 22 years ago and once said he could rule for 1 billion years. But on Thursday the Senegalese military headed toward the capital of Gambia, Banjul, where Jammeh has been holed up in the state house, insisting that his rule is still valid.

Jammeh has warned that he will fight back against any foreign military intervention.

At least 26,000 Gambians, worried about violence, have fled the country, the United Nations says, and several senior officials in Jammeh’s government have resigned in protest or have left the nation as well.

As the invasion began, the winner of the election, Adama Barrow, was being sworn into office in a brief ceremony about 150 miles outside of Gambia. The inauguration took place in a nondescript room at the Gambian Embassy in Dakar, Senegal, because Barrow has so little control over his country that he did not go home for the funeral of his son, who had been killed by a dog over the weekend.

Barrow’s team ultimately decided that the embassy in Dakar was the closest they could safely get to Gambian soil to start the new administration. Plans for an elaborate ceremony in a soccer stadium in Gambia’s capital had to be scrapped amid the standoff.

“It’s not necessarily the kind of ceremony to be jubilant about, but the situation is dangerous,” said Halif Sallah, a spokesman for Barrow.

But late on Thursday it appeared the situation could still be resolved without a fight. State television broadcast news that the presidents of Liberia, Mauritania and Guinea would arrive today to negotiate a peaceful resolution. A Senegalese military official said troops would stand by for talks to resume.

During the inauguration in Senegal, Barrow arrived to enthusiastic whoops from hundreds of supporters and emerged from a motorcade beaming in an all-white outfit. He was sworn in just before 5 p.m., his hand on a Quran, pledging to serve his country “without fear or failure.” Several people who had gathered outside to watch on a large television screen shouted, “No more dictatorship!”

In a brief speech, the soft-spoken Barrow called on the Gambian security forces to pledge their loyalty to him, asking that the military stay in their barracks.

“We are one Gambia, one people,” he said.

Gambia has suffered high unemployment and political repression for years under Jammeh, with many citizens abandoning the country to risk perilous and often deadly journeys to Europe by sea.

Minutes after Barrow was sworn in, celebrations erupted across Gambia, with thousands gathering in some areas.