NAIROBI, Kenya — A dispute between the speaker of the Somali Parliament and the country’s president briefly threatened on Wednesday to turn violent, the latest development in a complex controversy over the proposed leasing of a major port to a company controlled by the United Arab Emirates.

Conflict was avoided, partly because of the efforts of an African Union soldier, but the dispute also highlighted the fragility of the federal government under the leadership of its new president, Mohamed Abdullahi Mohamed, known by the nickname Farmajo, who was elected last year in a process marred by corruption.

Mr. Mohamed leads a weak federal government that is trying to wield power and influence over six states, while the Shabab, an offshoot of Al Qaeda, regularly challenges its rule with acts of terrorism.

Last year, Somaliland, a stable and semiautonomous region in the country’s north, signed a deal with DP World, a port management company based in the Emirates, to operate the port of Berbera.