President Aristides Royo resigned today in a surprise move described by a senior official as a "constitutional coup d'etat a la panamena" by the National Guard, intended to swing the government to the right.

The immediate victors in the push appear to be the National Guard commander, Gen. Ruben Dario Paredes; the intelligence chief, Col. Manuel Antonio Noriega; and Vice President Ricardo de la Espriella, who was sworn in as president this afternoon.

Paredes, whose National Guard is the country's sole military force, held a press conference after the swearing-in to order all newspapers shut down for seven days. He also demanded the resignations of all major figures in the Royo government.

The senior official, describing himself as "authorized" to speak for the new administration, said that as many as 70 percent of the resignations would be accepted and that "all the most notable leftist figures . . . will be left out" of the government.

Such figures might include Minister of the Presidency Ricardo Rodriguez and Interior and Justice Minister Jorge Ritter, according to well-informed Panamanians.

Royo himself had come to be considered the leader of leftist elements in the government. He was a constant critic of U.S. implementation of the treaties providing for transfer to Panama of control of the Panama Canal and Canal Zone. Internationally, he was regarded as a key link with Cuba in efforts to discuss worsening confrontations in the Central American and Caribbean regions.

The senior official, who is familiar with the thinking of senior guard commanders, said the force had in effect initiated a "purge" to clean up the government. He said that the shutting of the newspapers, including the forcible closing of the opposition daily La Prensa by guardsmen reportedly armed and carrying rubber hoses, was part of an effort to "moralize social communication" and "to avoid insults."

The official added, however, that after the week is over and "everything is established in order," then "a total democracy" will function, leading to presidential elections in 1984.

The ostensible reason for Royo's resignation is a throat malady, for which he is expected to travel to Houston early next week, the official said.

The coup comes in the wake of growing social unrest, scandal and discontent that National Guard leaders found increasingly disconcerting.

It also comes one day before the first anniversary of the death in a plane crash of Panama's strongman, general Omar Torrijos. Torrijos, who ran this country with a blend of social conscience, questionable practices and Machiavellian pragmatism for 13 years, handpicked Royo for a six-year term as president that began in 1978.

The then newly elected legislature had designated Royo and de la Espriella president and vice president for six-year terms in 1978 following Torrijos' decision to retire as head of state. However, he kept his job as National Guard commander, which is still widely considered to be the most powerful post in this country of 2 million.

Royo, 42, a Panama City lawyer and former education minister, was seen by many of his countrymen as a frequently ineffectual administrator who had no strong constituency of his own. De la Espriella, 48, on the other hand, has extensive backing among both business interests and the National Guard.

Frictions between Royo and the current commanders of the guard have been reported since Torrijos was killed. Royo was reported to have tendered his resignation the day after Torrijos' death, but the commanders of the guard declined to accept it at the time.

The Associated Press quoted a diplomat in Panama City as saying recent statements by Royo involving the United States and Cuba might have been a factor in the resignation. Royo returned Wednesday from Venezuela calling for a conference, to include Cuba but not the United States, to discuss "collective self-defense for the region" in the aftermath of the Falklands war.

In Washington, a State Department spokesman said, "We anticipate no change in our relations with Panama."

Paredes has been edging toward a bid for the presidency in recent months, and two weeks ago he openly undercut Royo's administration by saying that the people should have a chance to vote before 1984.

The somewhat mysterious and widely feared Noriega, meanwhile, is generally expected to succeed Paredes as head of the National Guard if Paredes makes his bid for the top office.

De la Espriella is the fourth new head of state to take office along the troubled Central American isthmus in the last seven months, following elections in Honduras, El Salvador and Costa Rica and a coup in Guatemala. Those four countries and Nicaragua compose Central America as a region, with Panama--once a province of Colombia--adhering more to South America.

The new president, who was known by friends to regard Royo as self-serving and egotistical, reportedly spent much of today huddled with National Guard leaders. The new president studied at Stanford University and at one point was an employe of the U.S. Agency for International Development mission in Panama.

Although there was some speculation that Royo's resignation may presage exactly the move toward earlier elections called for by National Guard Chief Paredes, one senior guard official, reached by telephone, said de la Espriella will probably finish out the two years remaining in the presidential term.

In the last few weeks, Panama has been hit by social discontent of a kind not seen here for several years, with striking teachers twice mounting massive demonstrations in the streets of the capital, a major scandal in the Social Security administration and increasingly bitter and militant opposition from political parties. Torrijos had tried to keep the parties out of national life, or on its margins, from the time he seized power in 1968.

In an interview earlier this month, Paredes talked about some of the changes he thought were necessary immediately in the national government, including "the need to review" the ministries to see which ones were working and which not and "to make them more efficient."

In a separate interview, Noriega noted that Torrijos had never wanted to see Nicaragua's revolutionary Sandinistas totally defeat the forces of dictator Anastasio Somoza's National Guard in 1979. Despite Torrijos' support for the Sandinistas, including arms shipments, Noriega insisted that Torrijos wanted Somoza out but "always fought for the Nicaraguan Army not to fall" and that now "there is a situation in Nicaragua which we all ought to keep from going beyond where it is now."