SAN SALVADOR, JULY 6 -- Caught between rising rebel activity in the capital and his own falling popularity, Salvadoran President Jose Napoleon Duarte is struggling to hold his political party together and contain mounting frustration in the armed forces, according to Salvadoran and western sources.

For six months, the 61-year-old president has been grappling with the devastating effects of an October 1986 earthquake, a resurgence of guerrilla activity by the Marxist Farabundo Marti National Liberation Front, a declining economy, labor unrest and concerns that a new U.S. immigration law will curtail the hundreds of millions of dollars that Salvadoran workers in the United States send home.

Some observers now see the economic troubles spilling over into the political realm. "There's a general disenchantment with the democratic process," a European diplomat said. "A lot of people are questioning what democracy has done for them."

The growing political disillusionment has been reflected in an open rift in Duarte's Christian Democratic Party and rumblings of discontent in the Army.

Duarte's difficulties have been complicated by the emergence of a charismatic and outspoken former Army officer in the political spotlight. Col. Sigifredo Ochoa, who resigned from the military last month and joined the right-wing National Republican Alliance, has started proclaiming that the military has the capability and the will to win the eight-year-old civil war but is being prevented from doing so by Duarte's government.

In speeches and interviews, Ochoa also has advanced the rightist line that the war is "good business" for certain unnamed officials. In addition, he has criticized sharply the U.S. role in the Salvadoran war and denounced the presence of American military advisers.

Duarte is on a four-day visit to West Germany. He won the presidency in 1984 in what was described by Washington as the first fair election in El Salvador in 50 years.

He is generally credited with having made progress in consolidating democracy and reducing human rights abuses, but the country remains mired in a costly war, and the economy shows no signs of recovery.

"It's a general malaise," said Donald Drysdale, the executive director of the American Chamber of Commerce of El Salvador. "There's no confidence in the long-term stability of this government -- not in the democratic sense but in the economic sense."

According to the chamber's estimates, combined unemployment and underemployment amount to about 50 percent of the labor force, inflation is running at about 40 percent this year and real wages declined at least 15 percent from last year.

Compounding the government's troubles was last year's earthquake, which caused an estimated $2 billion worth of damage, and the war, which is estimated to have drained $1.5 billion through economic sabotage, lost production and other costs.

The U.S. Congress' Arms Control and Foreign Policy Caucus reported recently that despite $2.7 billion in U.S. aid to El Salvador since 1980, per capita income has fallen about 32 percent since 1979 and continues to drop by 2 percent each year.

The caucus said fiscal 1987 U.S. aid of $474 million -- excluding supplemental requests that could push the figure to more than $700 million -- amounts to "a phenomenal 81 percent of El Salvador's $586 million federal budget, a ratio unmatched since U.S. foreign aid to Vietnam during the Vietnam War equaled 92 percent of Vietnam's budget."

Although El Salvador's next president is not scheduled to take office until June 1, 1989, a power struggle has already begun in the party over the succession to Duarte, who is limited to a single five-year term. Leading the main opposing camps are Communications Minister Adolfo Rey Prendes and Planning Minister Fidel Chavez Mena.

The rift has added to a perception that the party -- widely seen as obsessed with staying in power -- is foundering as it gears up for legislative elections in March 1988.

The party currently is considered likely to lose its majority in the 60-member National Assembly, which would make Duarte's task of governing even more difficult. The party now holds 33 seats.

The party's infighting got physical last week when two rival legislators brawled during a heated late-night debate behind closed doors at the party's headquarters over corruption charges and presidential candidacies. Legislator Jose Rigoberto Zelaya later filed criminal charges alleging that another assemblyman, Carlos Alberto Funes, had punched and kicked him.

Ochoa, who was known as one of the Salvadoran Army's most capable combat officers, was relieved of his brigade command by Duarte early last year after criticizing presidential policies and sent to Washington as a military attache. He is believed to have presidential ambitions but is barred from running in 1989 under a law that requires a three-year interval between service in the military and taking office as president.

Although extreme rightists have called for Duarte's resignation and periodically urged military officers to seize power, Ochoa has publicly expressed opposition to the idea of a military coup and Duarte, despite his troubles, is widely expected to finish his term. However, Salvadoran and foreign sources suggest that Ochoa's criticisms reflect sentiments that are widespread in the officer corps.

"I sense a lot of frustration," one military source said. He said officers were dismayed that the estimated 6,000 to 8,000 guerrillas have proved so persistent and have been able to escalate their activities in recent months, especially in the capital.

Salvadoran officers also have started to express concern that the United States will cut off aid to the Nicaragua's anti-Sandinista rebels, giving a major psychological boost to the rebel front and potentially freeing the Managua government to aid the Salvadoran guerrillas on a larger scale, the source said.

In addition, he said, "Ochoa has people nervous. Other officers are watching him with a fair amount of trepidation." They are worried that he could make public his knowledge of "where the skeletons are" in the armed forces, he said.

One indication of possible disgruntlement in the armed forces surfaced last month with the distribution of a statement purportedly written by a group of officers calling themselves the "National Military Council." The statement complained about "poor handling" of the government's problems, misuse of international aid and "the corruption of ministers and public officials at all levels, including some high military leaders."

The statement said the "excessive duration" of El Salvador's civil war was causing major discipline problems and "apathy toward combat." It also accused the government and the military high command of "obeying foreign sponsors" and of showing themselves "incompetent to govern and direct the war correctly."

Governmental and military sources said they believed the statement was the work of extreme rightist agitators, but could not rule out the possibility that it did come from the military.