Turkey's parliament has amended the code governing the armed forces, curtailing their political influence.
The original rules gave the military responsibility of preserving the Republic of Turkey, a clause previously used as a justification for coups.
It now says the army's main duty is to protect the nation from foreign threat.
The military has long regarded itself as the protector of Turkey's secular tradition and has staged three coups between 1960 and 1980.
But it has a history of tension with the Islamist-rooted Justice and Development Party (AKP) of Prime Minister Recep Tayyip Erdogan.
Since coming to power in 2003, Mr Erdogan has reduced the generals' powers through a series of reforms.
He has also put hundreds of officers, including top army commanders, on trial saying they were involved in plots against the government.
The amended code now redefines the military's responsibility as "defending the Turkish nation against external threats and dangers, and maintaining and strengthening military powers to ensure deterrence".
The AKP proposed the amendment following a wave of anti-government protests in June.
The demonstrators say the prime minister is being increasing authoritarian. He has accused his critics of conspiring against his democratically-elected government.