WASHINGTON — The Trump administration considered severely penalizing El Salvador this month for severing diplomatic ties with Taiwan in a move that officials said was intended to signal a significant widening of the administration’s pushback against China.

The effort ultimately fizzled over concerns that the penalties — eliminating some foreign aid and imposing visa restrictions on certain individuals — would have made El Salvador unwilling to help stop the flow of illegal immigrants to the United States.

The threat set off a furious internal debate between the White House and State Department, and pit American diplomats focused on China against those working on issues in the Western Hemisphere. It also displayed the administration’s determination to challenge China beyond a growing trade war, even before it settles on a clear strategy.

At the United Nations on Tuesday, President Trump announced the State Department would undertake a thorough review of foreign aid, giving it only “to those who respect us and, frankly, are our friends.”

He also cited “the encroachment of expansionist foreign powers” in the Western Hemisphere.

Beijing has been quietly carrying out a wide-ranging effort to vastly expand its trade and influence in Latin America, and in 2015, China passed the United States to become South America’s largest trading partner. In a speech on the eve of a trip through Latin America and the Caribbean in February, Rex W. Tillerson, the secretary of state at the time, warned about the dangers of the region’s growing ties with China.

The proposed penalties were raised by John R. Bolton, the national security adviser, three American officials said, after El Salvador established sovereign relations with China in August. It was the third Latin American country over the last year to do so; the Dominican Republic cut ties to Taiwan in May and Panama in June 2017.

China insists Taiwan is part of its territory. Currently, 17 nations have resisted recognizing Beijing’s diplomatic sovereignty, and China has been pushing harder against the last holdouts since Tsai Ing-wen, a critic of Beijing, became president of Taiwan in 2016.

The White House wanted to push back.

Mr. Bolton called President Salvador Sánchez Cerén of El Salvador and warned him not to sever diplomatic ties with Taiwan, a White House spokesman said.

In August, Mr. Sánchez did it anyway.

Mr. Bolton is a staunch defender of Taiwan. The pressure by the White House on other nations to maintain recognition of Taiwan instead of opening diplomatic relations with Beijing is awkward, given that the United States itself severed ties with the island in 1979 and recognized the People’s Republic of China.

Yet Washington views Taiwan’s de facto independence as important, in part because it serves as a check on China’s growing dominance in Asia. The United States sells arms to the island and has a diplomatic presence there through the American Institute in Taiwan.

In a blistering statement, the White House said Mr. Sánchez’s decision affected “the economic health and security of the entire Americas region.”

“The El Salvadoran government’s receptiveness to China’s apparent interference in the domestic politics of a Western Hemisphere country is of grave concern to the United States, and will result in a re-evaluation of our relationship with El Salvador,” the statement said.

An embassy for Taiwan in San Salvador. El Salvador was the third country over the last year to cut ties with Taiwan in favor of recognizing China.CreditMarvin Recinos/Agence France-Presse — Getty Images

That was followed by a threat from key Republican senators — Marco Rubio of Florida and Cory Gardner of Colorado — to push legislation to end foreign aid to El Salvador.

“Leftist leaders of #ElSalvador were clearly told ahead of time that switching from #Taiwan to #China would have negative impact on relations with U.S.,” Mr. Rubio tweeted, “but they either didn’t believe it or didn’t care. They will soon find out that this @POTUS doesn’t bluff.”

But the State Department warned that such punitive measures would undercut a host of other administration priorities — including attempts to deter Central American migrants who have flooded the southwestern border this year, seeking entry into the United States.

Diplomats noted that the Dominican Republic and Panama had already recognized Beijing, with little pushback from Washington. Mr. Trump had a warm meeting with President Juan Carlos Varela of Panama in June 2017 and had a hotel in Panama until partners evicted the Trump Organization’s management team.

State Department officials decided to call back the American chiefs of diplomatic missions from El Salvador, the Dominican Republic and Panama over the “recent decisions to no longer recognize Taiwan,” Heather Nauert, the department’s spokeswoman, said in a statement early this month.

But penalties were only considered against El Salvador, which received an estimated $140 million in American aid in 2017, including for narcotics controls, development and economic support. The proposed penalties, which included cuts to financial aid and targeted visa restrictions, would have been painful for the Central American country and its high unemployment and murder rates.

As internal meetings progressed, North American and Central American officials postponed a high-level conference focused on security and economic prosperity to follow up a similar gathering last year that was seen as a step forward in efforts to prevent migrants from heading to the United States.

But by mid-September, top administration officials made clear that they wanted the conference to go forward, effectively ending any consideration of penalties for El Salvador. Vice President Mike Pence is now slated to address the conference, now scheduled for mid-October, in a signal of the import the administration places on the gathering, the diplomats said.

And the three American envoys quietly returned to El Salvador, Panama and the Dominican Republic with no new tough messages or punishments from Washington.

A White House spokesman for Mr. Bolton declined to comment on the details of the debate that were described by the three American officials, including two diplomats, who agreed to discuss the internal deliberations on the condition of anonymity. Their accounts were corroborated by an outside analyst who is close to the administration and also spoke on the condition of anonymity.

The debate over El Salvador shows the difficulty in deeming whether certain nations are “friends” who are deserving of American aid, and Mr. Trump’s order for a State Department review of all recipients could be fraught.

Last week, the American Embassy in San Salvador released a statement dated Sept. 20 that summarized the three envoys’ discussions in Washington “about the decisions of those countries to end diplomatic relations with Taiwan.”

It warned countries throughout the region against pursuing “economic agreements and relationships with unfamiliar partners whose methods lack a proven, positive track record.”

“We note a disturbing trend that many of these transactions often lack transparency and do not serve the long-term interests of those countries,” the statement said.