For leftist politicians like Mr. Fuentes and Luis Redondo, a congressman, the caravan offered a perfect way to encourage migrants to travel safely in a large group — and attack the government at the same time.

After Honduras’s divisive presidential election in November, which the Organization of American States found so problematic that it called for a new vote, people took to the streets in deadly protests against what they saw as a fraudulent vote count.

Despite the controversy, the Trump administration gave its official support to Mr. Hernández, a loyal ally who cooperated with Americans during his first term on issues like stopping the flow of drugs and migrants toward the border. With that, Mr. Hernández took office, but he remained a polarizing figure accused of corruption and amassing too much power.

Determined to denounce Mr. Hernández’s administration and support the migrants, members of the opposition started promoting the caravan as an example of what happens when a government fails its people. In Tegucigalpa, the capital, a prominent member of the opposition went to the Mexican Embassy and threatened to send out multiple caravans as long as the situation in Honduras remained the same, according to two senior Mexican officials.

“This time it will be so big that when they see everyone walking, they should ask, ‘Where are they coming from and who is responsible for so many people leaving Honduras?’” said Mr. Redondo in a Facebook post on Oct. 5 in which he shared the caravan poster. “This is a consequence of corruption, lack of security, impunity; those responsible are the corrupt and corrupters of the national party.”

On that score, the government’s opponents were successful. Mr. Trump demanded that Mr. Hernández stop the caravan, though by then the migrants were already in Guatemala, and it was unclear what Mr. Hernández could do. Still, Mr. Trump threatened to cut off aid to the country if the caravan was not turned around.