The United States is prepared to guarantee President Anastasio Somoza's resignation and give massive economic aid to the guerrilla-backed exile government in exchange for its expansion to include more moderate elements, reliable sources here said today.

According to sources here, U.S. negotiators believe they have Somoza's agreement to step down. These sources said his resignation could come within the next few days if agreement is reached with the exile group headed by a provisional government junta.

In Washington, other sources said Somoza also is insisting that any replacement government "guarantee the integrity" of the Nicaraguan National Guard as a military institution and protect its officers against summary execution or other reprisals.

The Washington sources said Somoza, although willing to resign if he receives satisfactory assurances about the Guard, also warned that he otherwise will continue fighting until either his forces or the guerrillas of the Sandinista National Liberation Front decide the War militarily.

U.S. concern that a political solution to the crisis be reached is marked by a growing sense of urgency since the Sandinistas are believed to be within weeks of victory over the Guard.

The guerrillas were reported today to be on the verge of conquering National Guard garrisons in the southern cities of Jinotepe and Rivas, despite the arrival of government reinforcements. The Sandinistas already control large portions of the country.

Should a Sandinista victory be achieved, the United States believes it will have little alternative but to accept the junta as constituted or refuse to recognize it and relinquish all influence in Nicaragua.

Early this week, following consultations with Venezuela, Costa Rica and Panama, the United States dropped its plan for development of a separate conservative government in Nicaragua, the sources said. The plan had been refected as interventionist by both the provisional junta and the conservative opposition group it supposedly would have placed in power.

Instead, the United States and other concerned governments reportedly have circulated the names of at least five opposition Nicaraguans - whose politics range from liberal to what one analyst called "unapologetically reactionary" - as junta additions. Sources said that all or any of the names were considered acceptable balances to what the United States feels is the existing junta's far-left orientation.

Contacted in Costa Rica before being officially informed of the new plan, the junta initially rejected it as further U.S. intervention in Nicaraguan affairs.

"If any Nicaraguan group feels it is not represented in the junta government and wants to make suggestions, of course we would talk to them," junta member Sergio Ramirez said.

"But not if it is suggested by the United States or other foreigners," he added.

Sources said that the United States is hopeful that the offer of what one described as a "mini Marshall plan" to reconstruct the war-devastated country will be persuasive. They said the U.S. government believes growing anti-American sentiment here had prevented moderate opposition groups from expression what the United States feels is a shared concern about the junta composition.

At the same time, the United States seems to have no doubt that it has Somoza's resignation sewn up and that the junta can be influenced by the possibility of avoiding perhaps another month of bloodshed. The U.S. plan also includes conditions for a ceasefire.

It is not known what incentives, if any, were offered to Somoza.

The sources indicated that the desire to expand the junta with a more moderate balance stems more from unilateral U.S. concern than from any worry about Somoza's wishes.

That concern revolves around three of the junta's five members who are considered allied to what are believed to be Marxist factions of the Sandinistas. The United States is also concerned, as are some conservative Nicaraguans, about emerging evidence of bureaucratic power struggles among supposedly unified guerrilla factions within the Sandinista-occupied city of Leon.

Junta and Sandinista defenders, however, point out that only one of the five junta members, Daniel Ortega, is a Sandinista and that he belongs to the most moderate faction, which advocates a pluralistic democracy. The two others provoking concern, author Ramirez and university professor Moises Hasan, are considered here to be social democrats or socialists.

Somoza is not known to have left "the bunker," his office and residence inside National Guard headquarters here, since a nationwide speech nearly two weeks ago in which he vowed to remain in power. Reliable reports indicate that even his Cabinet has not been told of his decision to resign.

U.S. Ambassador Lawrence Pezzullo, who returned to Managua Wednesday from consultations in Washington, met with Somoza this afternoon but the embassy would not comment on their discussions.

Ambassador William Bowdler, a special Carter administration envoy who is negotiating with the junta in Costa Rica and with the Costa Rican government, arrived in San Jose Wednesday but left this morning for Panama without speaking to the provisional junta. U.S. ambassador to Panama Ambler Moss also attended the Washington meeting and returned to Panama Wednesday.

In a significant signal of the higher level of diplomats now handling the Nicaraguan crisis in the field, Viron Vaky, assistant secretary of state for Latin America, arrived in Venezuelan president Carlon Andres Perez, a strong Sandinista supporter.

An informed source said Vaky, who served as U.S. ambassador to Venezuela until last year, was scheduled to continue his trip "south" to other unnamed Latin American countries.

Venezuela, Costa Rica and Panama have been the firmest Somoza opponents and strongest Sandinista backers in Latin America. While they have all rejected recent U.S. attempts to intervene in Nicaragua, sources said the United States feels it now has convinced substantial elements within their governments to help arrange an expansion of the junta.

With a Sandinista military victory thought to be just around the corner, the United States hopes that as long as it agrees to the existing junta members, the others will help it arrange an expansion. While recognizing widespread popular support here for both the guerrillas and the junta, the United States hopes the others will agree that the hemisphere's democracies should take no chances of allowing Eastern Bloc influence to extend beyond Cuba.

The U.S. plan, sources said, calls for Somoza to relinquish power to someone in the Nicaraguan Congress who would then resign in favor of the expanded junta. The United States, they said, is counting on the Latin Americans to help persuade the junta, while it takes care of getting rid of Somaza.

Washington Post correspondent John Goshko reported from Washington:

Although State Department officials refused to elaborate on assistant secretary Vaky's mission, it was learned that he is trying to enlist the five-nation Andean Pack countries in attempts to intercede with the Sandinistas. The Andean Pact has shown strong sympathy for the Sandinistas cause in the Nicaraguan conflict.

Specifically, Vaky is understood to be seeking help in convincing the Sandinistas that they should accept a broadened post-Somoza government and in inducing the other Latin governments to join with the United States to provide a large-scale economic aid program to the new government.

Vaky is understood to be counting especially on Venezuela, which is the richest and most influential of the pact members and which has been troubled in the past by Cuban-aided subversion. CAPTION: Picture 1, A Sandinista guerrilla stands guard beside a road leading into Matagalpa. AP; Picture 2, The insurgent leader in Matagalpa, known as Commander Camino, walks ahead of aides through barracks. AP