Nigeria’s president on Friday suspended the country’s chief justice just three weeks before the presidential election and an expected court challenge to the results, while the president’s top rival called the move “an act of dictatorship.”

The decision by President Muhammadu Buhari, who seeks a second term in the Feb. 16 vote, sent Africa’s most populous country into a constitutional crisis. It was not immediately clear whether the president has the authority to suspend a chief justice.

Observers already have warned that the vote could lead to violence — Mr. Buhari’s election in 2015 was a rare peaceful transfer of power in oil-rich Nigeria — and diplomats have urged the top candidates to sign a peace pledge.

The chief justice, Walter Nkanu Samuel Onnoghen, faces trial on charges of failing to declare his assets. Mr. Buhari said his suspension will continue until the case is concluded. This is the first time a chief justice is standing trial in Nigeria, where corruption is widespread. Justice Onnoghen said the charges are meritless.