MIAMI, JAN. 1 -- A close adviser to Panamanian President Guillermo Endara resigned Monday in a storm of criticism over his direction of a new security agency.

Menalco Solis, a former law partner of Endara's, said he quit as chief of the Council on Public Security and National Defense because of "the lack of confidence expressed by several legislators and media outlets." Accounts last week said the council, which had operated since July, had hired about 100 agents and employees and was receiving aid from the CIA.

A number of Panamanians raised questions about Solis, who was treasury secretary in one of the puppet civilian governments of ousted dictator Gen. Manuel Antonio Noriega. Solis left the Noriega government in the mid-1980s and ran a beachfront fruit stand until Endara tapped him as an adviser early last year.

There was also criticism of the involvement of the CIA, whose links to Noriega are a sensitive subject in Panama. The CIA maintained a long relationship with Noriega, reportedly paying him up to $200,000 a year for information on Cuba, Nicaragua and other adversaries of the Reagan administration.

Last week, the Legislative Assembly called for a commission to investigate the activities of Solis and the new agency. Endara angrily opposed the move, asserting that national security was the exclusive responsibility of the president under the constitution.

In a front-page editorial Sunday, the independent newspaper La Prensa called Solis a "servant of the {Noriega} dictatorship" and compared the new agency to the Soviet KGB and the Nazi Gestapo.

"All real democrats must unite to strangle this monster in its cradle before it grows," the paper said.

Solis and the council were working from temporary offices in the presidential palace. The origin of funds for the agency is unclear, but several high-ranking officials, including the one responsible for finance, said they did not believe the new agency was funded by the government. However, Endara, in a letter to a lawmaker last week, suggested that the agency's funding had been included in the 1991 budget.