Venezuela’s president sought to strengthen his image as the undisputed commander of the armed forces on Thursday, mustering troops in a televised show of authority days after the opposition tried to incite a military mutiny that fizzled within hours.

The president, Nicolás Maduro, was dressed in green fatigues and a cap as he waved and spoke to soldiers at a military base in Caracas, the capital. The event seemed intended to further contradict assertions by Juan Guaidó, the opposition leader, that the armed forces were switching their allegiance to him as the economy lurches toward collapse.

“Soldiers of the fatherland, it’s time to fight!” Mr. Maduro said to hundreds of soldiers at the Fuerte Tiuna base.

Mr. Guaidó, who leads the opposition-controlled National Assembly, declared himself interim president more than three months ago, asserting that Mr. Maduro was a corrupt, illegitimate and incompetent autocrat who had stifled dissent and remained in power through an election widely believed to be fraudulent.