Peruvian troops were ordered today to cease fire unless "under attack" in the country's border conflict with Ecuador, the government announced, saying all Ecuadoran troops had been driven out.

The official news agency said the decision was communicated to the embassies of the four guarantor countries of a 1942 protocol -- the United States, Argentina, Brazil and Chile. The protocol established all but 50 miles of a boundary line between the Andean nations. Ecuador has since said it is not bound by the accord. Nevertheless, Ecuador indicated earlier in the five-day flareup that it would accept a cease-fire.

Pope John Paul II today joined the pleas for a halt in the hostilities. The protocol guarantor states, led by Brazil, had made a similar plea yesterday.Peru and Ecuador, both members of the Andean regional economic integration pact, in the last two years initiated a return to democratic rule among South American republics.

"The government of Peru informed the embassies of the guarantor countries accredited in Lima that orders have been given to our forces to the effect of ceasing fire when not under attack," the Peruvian announcement said.

[In Quito, where Ecuadoran President Jaime Roldos earlier had declared a state of emergency, a spokesman called the cease-fire a trick and said "Peru is pursuing its aggression."]

Peru's deputy foreign minister made the cease-fire declaration since the minister was already in Washington for a meeting of the Organization of American States scheduled for Monday.

The border in dispute is isolated and casualties are thought to have been minimal.

Ecuador charged that a Peruvian helicopter on Tuesday attacked a post at Paquisha, clearly in Ecuador. Peru said Ecuadoran troops crossed into Peru and established a "false Paquisha" that, along with two other posts, have now been dismantled.