The night before Juan Guaidó declared himself interim president of Venezuela, the opposition leader received a phone call from Vice President Mike Pence.

Mr. Pence pledged that the U.S. would back Mr. Guaidó if he seized the reins of government from Nicolás Maduro by invoking a clause in the South American country’s constitution, a senior administration official said.

That late-night call set in motion a plan that had been developed in secret over the preceding several weeks, accompanied by talks between U.S. officials, allies, lawmakers and key Venezuelan opposition figures, including Mr. Guaidó himself.

It culminated in the 35-year-old Mr. Guaidó’s declaration Wednesday that Mr. Maduro’s government was illegitimate and that Mr. Guaidó, president of the country’s National Assembly, was assuming power in accordance with the country’s constitution.

Almost instantly, just as Mr. Pence had promised, President Trump issued a statement recognizing Mr. Guaidó as the country’s rightful leader. Soon after came similar pronouncements from Canada, Brazil, Argentina, Colombia, Chile, Peru and others.