Commanders of the Bolivian armed forces seized power today to thwart the impending election of a constitutional left-wing government. They declared that President Lidia Gueler, who was detained earlier in the day, had resigned.

Shots rang out sporadically in the streets of the 12,000-foot-high capital, which was thick with troops armed for combat.

An Army radio station, broadcasting in the name of the Army, Air Force and Navy commanders, declared invalid the recent first-round elections, won by leftist ex-president Hernan Siles Zuazo. It said the Congress that was to elect him formally next month was "unconstitutional."

At least one Communist Party member and a labor leader were reported dead, several leftists arrested and the whereabouts of many other Bolivians -- including Gueiler -- unknown.

Up in 20 Bolivian journalists were under detention.

[In Washington, the State Department said it "deplores the reported coup attempt in Bolivia and the accompanying violence." It announced cutoff in all security aid and refusal to consider further economic aid "pending clarification."]

The U.S. government has supported the efforts of this coup-prone, land-locked country of 5 million people to break out of the pattern of right-wing military rule that has dominated lower South America for most of this decade.

According to initial reports, Gueiler and her Cabinet were taken prisoner after armed forces in civilian dress took over the Quemado Palace. The name means "burned palace," coming from one of the 155 previous coups since independence from Spain in 1825.

Later, an unidentified receptionist at the presidential residence said Gueiler, 51, was "resting" there and an unconfirmed report said she would be allowed to take refuge in an embassy.

Other reports said troops had ringed Latin American embassies to prevent opponents of the military from seeking asylum. A night curfew was in effect throughout the country.

The charismatic leader of Bolivia's tin miners, Juan Lechin Oquendo, was said to have been taken prisoner by the rightist para-military forces that cooperated closely with the military.

While forces in civilian garb initiated action here, Army regiments in the eastern cities of Trinidad and Santa Cruz seized government buildings and called for the overall takeover.

Communist member of Congress Simon Reyes was reported killed in one of several assaults laid to rightwing gunmen. Reports were difficult to confirm because of major efforts by troops to prevent circulation of news on the day's events.

"This bunch isn't going to make the same mistake that Natusch did," said a diplomat, recalling the abortive right-wing coup by Army Col. Alberto Natusch Busch in November. "They're going to make sure that the outside world doesn't know what these fascists are doing."

While troops concentrated around the downtown university, a center of leftist opposition, there were ample calls for resistance. Siles reportedly made could a call clandestinely.

The junta of Army Gen. Luis Garcia Meza, Air Force Gen. Waldo Bernai and Adm. Oscar Terrasas said "terrorism will be drastically repressed." Bolivia's Navy consists of patrol boats on Lake Titicaca.

"We're going to resist the coup to the ultimate consequences," declared the mineworker organization in cities 150 and 200 miles from La Paz. "Never are we going to work for these exploiters," one broadcast said.

Bolivia's tin miners defeated the military in Bolivia's 1952 revolution that substantially altered the political, economic and social structure of this country, lifting the Indian Majority from peonage. Last November even after the general strike was lifted, the tin miners refused to work until Natusch left the palace.

The unions again today called for a general strike and civilians were building barricades.

Uniformed soldiers entered at least one foreign news bureau, seized stories that were being filed on the insurrection and ordered all journalists to leave. The journalists' communications outside the country were repeatedly cut off.

[Siles' vice presidential candidate, Jaime Paz, issued a statement in Washington, where he is a visitor, calling on "the Bolivian people, labor unions, peasants and the middle class . . . to resist by all means the intent of the restoration of the dictatorship, and engage in active struggle for democracy and freedom."]

The rightist insurrection follows a two-year period of political upheaval -- including two coups, a 16-day bloody military siege and six presidents -- that has been extreme even in the context of Bolivia's turbulent history.

The elections held in 1978 were the first in almost 15 years, the interim had seen a succession of military leaders -- including six uniformed men successively occupying the presidential seat during one 24-hour period -- and concluded with seven years of relative stability imposed by rightist Gen. Hugo Banzer.

Throughout the last two years, the United States has played a significant role in prodding Bolivians toward democracy. The Carter administration has made Bolivia one of the largest recipients of economic assistance in Latin America, with nearly $200 million scheduled for 1980.

U.S. relations with the military have been severely strained since last year, following an earlier election in which no candidate won an absolute majority and a civilian president was selected by the Congress. That president, Walter Guevara Arce, was overthrown by Col. Natusch.

Natusch lasted 16 days, during which the United States reportedly threatened to cut off all aid and union and student organizations organized strong resistance in the streets and a paralyzing general strike. Congress then appointed Gueiler as interim president, the first woman to hold the office in Bolivia and the second in a Latin America. She was to govern until her successor was inaugurated Aug. 6.

The military exerted strong pressure on Gueiler throughout the past seven months, circumventing her policies and forcing the appointment of a hard-liner to replace her own choice of a moderate to head the Army.

Before the July 29 elections, the military warned that neither of the leading candidates, Siles or ex-president Victor Paz Estenssoro, was acceptable to the armed forces. An earlier coup attempt was averted in late May, reportedly following strong U.S. pressure, and State Department spokesman at that time warned that the United States supported the "continuation of the democratization process in Bolivia."

Those statements so angered the military, which accused the United States of interference in the internal affairs of the country, that it gave U.S. Ambassador Marvin Weissman 72 hours to leave the country and called on Gueiler to declare him persona non grata.

Gueiler ignored the demands and appeared to have come to an accommodation with the military. Last weekend, however, the government announced official vote tabulations that showed Siles with a substantial margin.

Weissman is now in La Paz.