MANILA, Philippines (AP) _ The Roman Catholic hierarchy today told priests and nuns to stay out of politics and movements that espouse class struggle and violence following the military's claim the church had been infiltrated by Communists.

The call was issued by Cardinal Jaime L. Sin, archbishop of Manila, and three capital area bishops during a breakfast forum for reporters.

Bishop Teodoro Bacani said the Philippine church must undertake a ''cleansing of ranks'' because politicized priests and nuns ''are undermining the church's credibility.''

Cardinal Sin, the country's most prominent cleric, released a document forbidding priests from running for public office without approval of their bishop.

Chief of Staff Gen. Fidel V. Ramos told troops Tuesday in Butuan City on northern Mindanao island that the church had been infiltrated by Communists.

On Thursday, the military announced it had captured a priest with a band of New People's Army rebels on Mindanao.

Later today, police announced that weapons charges had been filed against a priest, Rev. Rogelio Arguelles, after troops found a weapon, ammunition and ''subversive literature'' in his rectory on rural Panay island.

Last year, Rev. Rustico Tan, a member of the Communist-dominated National Democratic Front in the Cebu City area, said more than 20 priests and nuns were working with the Communist underground in the central Visayas islands.

The document released by Cardinal Sin states that a priest is free to vote for candidates of his choice but ''he cannot run for election or accept appointment to a position which demands the exercise of civil power... .He should not campaign for any political party or candidate.''

He said it was based on documents submitted by the Catholic Bishops' Conference of the Philippines in advance of the May 11 congressional election and the Aug. 23 vote for local and regional posts.

Sin said local bishops had the authority to grant exemptions to the ban on running for office ''if he finds it necessary.''

The document, entitled ''A Catechism On The Involvement of Priests In Political Activity,'' tells priests to work for social justice and to defend human rights, but it bans them from membership in organizations ''that advocate class struggle or violence as a means to social change.''

''The Philippine hierachy has forbidden priests to join or support such organizations or movements,'' the document states.

The cardinal in February 1986 called thousands of people into the streets to protect military officers who mutinied against former President Ferdinand E. Marcos. That call triggered the ''people power'' revolution which deposed Marcos and propelled Mrs. Aquino to office.

The cardinal has said he was not motivated by politics but wanted to save the lives of the mutineers.

In a statement published Tuesday in the daily newspaper Malaya, the Christians for National Liberation denounced ''the ultra-right church people'' who it said were fomenting ''anti-Communist hysteria.''

The CNL is one of 12 organizations in the National Democratic Front. The New People's Army, which is also part of the front, has been fighting an insurgency for 18 years.

''We condemn Cardinal Sin's moral blessing of the Aquino government's declaration of war against the revolutionary forces,'' the CNL said.

It also claimed that despite calls for non-involvement in politics, the church was sanctioning efforts by conservative clerics in support of anti- Communist organizations.