The minister of war and the chief of staff of the armed forces were removed from their posts yesterday as part of President Anwar Sadat's major overhaul of the Egyptian military leadership.

Coming so soon after the Camp David agreements and only three days before the annual military parade at which they would have presided, the removal of Gen. Mohammed Abdelghani Gamassi, the minister of war and commander in chief, and Lt. Gen. Mohammed Ali Fahmi, the chief of staff, touched off speculations about unrest among top officers over the terms Sadat accepted for peace with Israel.

Egyptian military and political sources said last night, however, that there is no evidence for any such theory. Diplomatic specialists agreed that Sadat appeared to be fulfilling the pledge he made in a speech Monday to bring a younger generation of military and political leaders into the government to conduct the delicate transition from war to peace.

Both Gamassi and Fahmi publicly supported the Camp David agreements and, according to Cairo Radio, both are to remain as military advisers to Sadat. In addition, Gamassi will be part of the delegation Sadat is sending to Washington next week to conduct negotiations with Israel on terms of a peace treaty and may even be named to head it, authoritative sources said.

A shakeup in the military leadership had been rumored for some time. Sadat's decision to let Gamassi and Fahmi go now, like his acceptance Monday of the resignation of Prime Minister Mandouh Salem, appears to be part of his campaign to show the Egyptian people, and rest of the world, that his country has left war behind for good.

Cairo radio announced that Gen. Ahmed Badawi, former commander of the Third Army, would succeed Fahmi as chief of staff. Military officials noted that Badawi graduated from the military academy in 1948, nine years after Gamassi and Fahmi, and is thus closer to what Sadat calls "the October generation," brought to prominence by the October 1973 war with Israel. It is this generation that Sadat says must carry out the transformation of the country.

No successor to Gamassi as minister of war and war production was announced. The new prime minister, Mustapha Khalil, is expected to name a war minister when he introduces his Cabinet tomorrow. Informed observers predicted last night that the post would go to Gen. Kamal Eddin Hassan Ali, a former armored brigade commander who as chief of intelligence is already a member of the National Security Council, Sadat's panel of top advisers.

Ali met with Sadat yesterday and their talk was prominently featured on last night's television news.

The end of Gamassi's tenure as minister of war removes from the scene as officer who was probably the second most powerful man in Egypt, but who never sought to capitalize on his position to develop a personal following or challenge Sadat's policies.

Simultaneously, minister of war production, he was also a deputy prime minister, commander in chief of the armed forces and Egypt's representative on the board of directors of the four-nation consortium trying to develop and indigenous Arab arms industry.

Experienced observers were predicting last night that some of these posts will be broken up or redivided so that no one officer will hold so many positions of power in the future.