MOGADISHU — Sporadic gun and mortar fire could be heard in central Mogadishu on Friday morning amid a lockdown imposed by the Somali government — a measure ostensibly intended to enforce social distancing but timed to coincide with mass protests called by opposition parties.

Somalia has been in a constitutional crisis for nearly two weeks after an agreed-upon election date, Feb. 8, passed with no vo­ting, leaving President Mohamed Abdullahi Mohamed, widely known as “Farmajo,” without a mandate, his opponents said.

Negotiations on a new date have failed, and Somalia’s fragile politics have exploded into violent acrimony. Political chaos could unravel a decade’s work in shoring up the stability of the federal government, which is trying to recover control over the country’s territory and economy from the al-Qaeda-affiliated militant group al-Shabab.

Early Friday, a hotel where two major opposition candidates were staying came under heavy gunfire in what one — Farmajo’s former deputy, Hassan Ali Khaire — called a crude assassination attempt.

Another candidate, former president Sharif Ahmed, said the “attack was ordered by outgoing president Mohamed Farmajo.”

Later on Friday, a street protest led by Khaire came under fire, and videos shared by journalists on social media showed him and supporters ducking for cover. Local authorities announced the closure of Mogadishu’s airport.

“I am very sorry for what happened last night and this morning in Mogadishu,” Mohamed Hussein Roble, the prime minister, said in a recorded address. “We tried our best to avoid it. Peaceful demonstrations are a constitutional right, but armed demonstrations are not. Elections will take place, and I say to the people: Do not let the peace you have suffered for be destroyed.”

Roble did not say whether government forces shot at protesters or whether he considered opposition candidates’ security details to be protesters.

The process of moving toward eventual elections seemed as precarious as ever on Friday, with what was essentially a political stalemate devolving into gunfire in Mogadishu’s streets.

“It’s a moment of great uncertainty. There’s still no consensus on how to move forward, and the opposition is getting frustrated. This has resulted in the clashes in Mogadishu this morning, as they moved ahead to organize protests,” said Omar Mahmood, senior analyst for Somalia at the International Crisis Group.

The protests in Mogadishu had been called by Abdirahman Abdishakur, an opposition candidate who has repeatedly accused Farmajo of seeking to stay in power indefinitely through manipulation of the election and collusion with the director of the national intelligence agency. With the election’s date undetermined for now, Abdishakur has been calling for Farmajo to resign.

“They are occupying Somalia without any political mandate,” he said in a phone interview. “He should not believe that he can get away with it. He cannot create such a dangerous precedent. This supposed leader has shown no desire to compromise, and now he has lost his legitimacy. So we will mobilize the people.”