In an apparent response to President Carter's human-rights policy, Nicaragua's military leader Gen. Anastasio Somoza yesterday lifted a state of siege imposed three years ago.

The move was expected to clear the way for the signing of a $2.5 million military agreement, held up because of charges that the Somoza government was violating Nicaraguan's rights.

Two high-ranking Nicaraguan officials were told during recent visits here that the sale of arms on favourable credit terms for fiscal year 1977 could not take place unless martial law was lifted, Washington sources who follow human-rights issues said.

The Somoza government has recently been the target of criticism from liberals on Capitol Hill church groups and other human-rights activists.

During hearings in April on alleged human-rights violations in Nicaragua, a State Department official pledged that no new military aid agreement would be signed until the department had evidence that the situation was improving.

The U.S. embassy in Managua, the Nicaraguan capital, and officials in Washington have been urging Somoza's government to lift martial law and censorship imposed in 1974 after a guerrilla attack on a diplomatic reception in Managua. Four people were killed in the attack.

State Department and other sources said human rights was a topic during meetings between U.S. officials and the two high-ranking Nicaraguans who visited here recently.

Cornelio Hueck, president of the Nicaraguan Congress, was in Washington this month for the signing of the Panama Canal treaties.He met with Vice President Mondale and State Department officials.

Harry Bodan-Shields, deputy foreign minister, visited Washington and New York last week. He met with U.S. Ambassador to the United Nations Andrew Young and Patt Derian, the State Department's top-ranking human-rights officer.

Both men were reportedly told that if the 1977 military-aid agreement was not signed by Sept. 30, the arms sales would not go through at all. Another $2.5 million military-aid request for fiscal year 1978 is still before Congress.

Francisco Celedon, minister-counselor of the Nicaraguan embassy, said his government had lifted the state of siege because the guerrilla threat is "under control."

The Nicaraguan government has maintained that the state of siege, which suspends constitutional guarantees such as freedom of the press, was necessary because of guerrilla activity. Critics of the Somoza government said the guerrilla organization in Nicaragua is small and weak, and the state of siege was used to repress opponents of the government.

During congressional hearings last year, a number of Nicaraguans and foreign clerics testified that hundreds of peasants had been killed by members of the National Guard, a combined military and police force that has been fighting the guerrillas.