All praise is due to Allah, and peace and blessings be upon our Master, the Messenger of Allah.
Among the well-established legal principles in our noble Sharia is that contracts are binding upon the contracting parties. Therefore, if a partner sets a condition upon their co-partner which serves a valid purpose—such as stipulating that they may not establish a competing business during the partnership , term—then such a condition is valid and binding. Since Allah The Almighty Says: "O you who believe! Fulfill [all] contracts." [Al-Ma’idah/1]. Besides, the Prophet (PBUH) said: "Muslims are bound by their conditions, unless the condition permits what is unlawful or prohibits what is lawful." [At-Tirmidhi]. Thusly, this kind of condition is valid because it serves the interest of one of the parties and prevents potential harm.
As for stipulating that a partner may not establish a similar or competing business after terminating the partnership contract, then such a condition is invalid and carries no legal weight, as it places an undue restriction on the partner without legitimate cause. The Messenger of Allah (PBUH) said: "Any condition that is not in the Book of Allah is invalid." [Agreed upon].
We also note here that it is not permissible for a former partner, after the dissolution of the partnership, to act in a way that harms the former company, such as by deliberately taking its clients, based on the hadith of the Prophet (PBUH), it states: "There should be neither harm nor reciprocating harm." [Ahmad]
Accordingly, stipulating a non-compete clause during the partnership period is valid, while stipulating such a restriction after the partnership ends is invalid and unenforceable. And Allah The Almighty Knows Best.