The four Libyan planes carrying Soviet arms to Nicaragua that were grounded in Brazil last week have turned out to be "a tremendous gift" to President Reagan, a State Department official said yesterday.

Officials in the Pentagon and the White House echoed those sentiments when discussing the impact of the Libyan plane incident just before Reagan's scheduled speech on Central America to a special joint session of Congress Wednesday.

The White House has said Reagan will use the incident to back up his contention that the United States must increase military aid to the government in El Salvador to counter outside support for leftist guerrillas there.

"If you wanted to design a gift for Reagan," one official said, "you couldn't find a better one. All his enemies are wrapped up in those planes: the Libyans, the Russians, the Nicaraguans and the rebels in El Salvador."

There also are indications that U.S. intelligence may have had a role in the incident. Government sources said that the Libyan planes' highly unusual stop in Brazil en route to Nicaragua caught the attention of U.S. specialists.

They said the Brazilian government also was tipped off by Washington that the planes were carrying arms rather than medical supplies to Nicaragua. American officials said the Brazilians have been very cooperative throughout the incident.

Sources also suggested that the neighboring country of Venezuela declined to give overflight rights to the Libyan aircraft, which is said to have complicated the intended Libyan flight plan from Brazil to Nicaragua.