What is the Islamic stand when the man and woman marry each other on condition that they will divorce after a specified period of time?

Question

If there was agreement between the two spouses, or between the husband and the woman’s guardian, that the marriage would be temporary and last for a set period of time, and that agreement was at the time of the contract or before it, then the marriage is invalid, because it is a Mut’ah (temporary) marriage, even if all the necessary conditions of marriage were fulfilled.