Mexico has warned the United States that any military action against Nicaragua or Cuba would be a "gigantic historical error" and suggested that Washington moderate its rhetoric to relieve the dangerous political situation in the Caribbean Basin, a Mexican official said today.

Foreign Minister Jorge Castaneda said at a news briefing that Mexican President Jose Lopez Portillo delivered this message to U.S. Secretary of State Alexander M. Haig Jr. who ended a 24-hour visit here today.

Summarizing today's talks, Castaneda said that Haig had told the president "openly, categorically and unconditionally that for the moment the United States would not intervene militarily" in Nicaragua or Cuba.

Privately, Mexican officials repeated their position that the continuing hints of military action from Washington are destabilizing and contribute to political polarization in the region. Several days ago Lopez Portillo referred to those hints as "an escalation of verbal terrorism" that was coming from both camps.

Mexico offered to act as a go-between in the U.S. dispute with Nicaragua, but a senior official said Mexico was "not interested in making unilateral representations to Nicaragua." The source said Mexico pointed out to Haig Nicaragua had built up its Army because of threats by the United States and by armed groups in Florida and Honduras.