A police contingent loyal to a top opposition leader in Somalia took over Parliament for several hours on Wednesday, pushing a growing political rift to the brink of armed confrontation.

Parliamentary police officers loyal to Mohamed Osman Jawari, the Parliament speaker, disrupted a no-confidence vote against him early Wednesday. The police lined up to block the speaker’s podium, and lawmakers who support Mr. Jawari accused other legislators of taking money to vote against the speaker, chanting, “Down with bribetakers!”

Supporters of the no-confidence motion said the police had refused to let them inside the

In response, state security forces loyal to President Mohamed Abdullahi Mohamed, who is known as Farmajo, deployed outside the Parliament building, raising fear that tensions between the two men could erupt into an armed confrontation.

Mr. Jawari has been at odds with Somalia’s president since mid-March, when the speaker mustered a usually fractious Parliament to vote unanimously against a foreign investor. The signal of Mr. Jawari’s political strength, and of parliamentary independence, surprised and scared the president.

A move for a no-confidence vote against Mr. Jawari followed, but it, too, was delayed by a security standoff: Parliamentary police officers were dismissed and replaced with people believed to be loyal to the president. Mr. Jawari’s supporters said the security change sought to intimidate the opposition.

Mr. Jawari said at a news conference last month that the effort to oust him was intended to “dismantle the Parliament,” which he said has been “under attack by the executive branch.”

Pro-Jawari lawmakers said on Wednesday that delays made any vote on the no-confidence measure unconstitutional.

Soldiers from the Somali National Army, as well as officers from the Presidential Guard and the intelligence services, joined African Union troops to secure the area and protect the lawmakers locked outside.

Soldiers from Danab, the Somali special forces contingent trained by the United States, were also deployed to secure the Parliament.