MEXICO CITY — For Mexico, the nightmare came true.

Perhaps no country aside from the United States itself had as much at stake in the American presidential election as Mexico did.

Then, early on Wednesday, it watched as Donald J. Trump became the next American president: a man whose central campaign promises included building a wall between the two countries, upending decades-old trade deals and deporting millions of Mexican immigrants.

The peso suffered its largest drop in nearly 20 years, and for many, the election set back years of carefully cultivated efforts to improve the cross-border relationship, one that has been historically fraught. The outcome promises a turbulent financial future for Mexico, which relies on America as an economic lifeline, both in terms of trade and remittances.

“It’s an unmitigated disaster,” said Jorge Castañeda, a former foreign minister of Mexico and a professor of politics and Latin American studies at New York University. “There are very few tools to fix the relationship.”