BEIRUT, Lebanon (AP) _ Rival Shiite Moslem factions agreed today to end their bloody 3-year power struggle, which has claimed the lives of more than 1,100 people.

Also today, the government of President Elias Hrawi announced that the four principal Moslem and Christian militias who fought a 15-year-old civil war that left 150,000 dead have agreed to move out of Beirut.

Efforts to end factional fighting accelerated after Syria, with an estimated 40,000 troops in Lebanon, helped the government crush Christian Gen. Michel Aoun's 11-month-old mutiny on Oct. 13.

The two Shiite militias - the pro-Iranian Hezbollah, or Party of God, and Syrian-backed Amal - issued a joint communique today saying a ''comprehensive cease-fire'' in their confrontation began at midnight Tuesday.

The communique said representatives of the two factions would ''work out a plan for the exchange of prisoners pending the achievement of a comprehensive and final settlement (to the conflict) under the auspices of Syria and Iran.''

Hezbollah is the umbrella group for kidnappers believed holding 13 Western hostages, including six Americans.

Shiite sources have said Hezbollah moved the hostages out of the south Beirut slums before the crackdown on Aoun, anticipating they would lose their strongholds in the capital as the government implemented its peace plan.

The reports could not be independently confirmed.

The cease-fire, the latest in a series of agreements aimed at containing the inter-Shiite bloobath, climaxed a series of meetings of senior commanders from both sides. Brig. Gen. Ghazi Kenaan, commander of the Syrian army's military intelligence in Lebanon, chaired the talks.

The meetings at Kenaan's office in the east Lebanon's town of Anjar were also attended by Iran's ambassador to Syria, Mohammad Akhtari.

Police said no truce violations were reported in Beirut, south or east Lebanon where both sides have bases.

The particularly tense Iqlim al-Tuffah, or Apple Province, which had witnessed some of the bloodiest rounds of the Hezbollah-Amal war, was quiet.

But a police spokesman, who spoke anonymously in line with regulations, said fighters of both factions maintained positions facing each other in the disputed mountain terrain above the southern port city of Sidon.

Hezbollah and Amal, vying for mastery of the 1.2 million Shiites in Lebanon, have fought intermittently since June 1987. By police count, 1,100 people have been killed and 3,222 wounded in the struggle.

Both Amal and Hezbollah have been among the four militias to agree to the militia-free greater Beirut plan. The other two are the right-wing Christian Lebanese Forces and the Druse Progressive Socialist Party.

''We break the good news to the Lebanese citizens who are longing for peace. The Lebanese Forces militia reacted positively to the government plan for the creation of the greater Beirut,'' Agriculture Minister Mohsen Dalloul announced after a five-hour meeting with Samir Geagea, the militia's leader.

The session also was attended by Defense Minister Albert Mansour.

Hrawi had assigned Dalloul, a Shiite, and Mansour, a Greek Catholic, to discuss the greater Beirut plan with militia leaders and work out details of the withdrawals.

''All the militias have agreed to withdraw from greater Beirut,'' Dalloul told reporters. No deadline has been set for the pullout.

The proposed greater Beirut extends along a 15-mile stretch from the Dog River in the north to the Damour River in the south and covers the city's eastern and southeastern suburbs.

The government peace plan also aims to give equal political power to Christians and Moslems, effectively shifting power to the Moslem majority.

Until recently, Christians had maintained political dominance despite their declining demographic strength.