*And they both raced to the door, and she tore his shirt from the back...*
(And they both raced to the door) is connected to His saying, Exalted is He, (And she had certainly desired him, and he would have desired her), etc.
His saying, Exalted is He, (Thus), etc., is a parenthetical clause brought between the two conjoined parts to affirm the innocence of him, peace be upon him. The meaning is: She desired him, but he refused, and they both "raced"—meaning they competed toward the door, each intending to reach it before the other. He intended to reach it to exit, and she intended to reach it to prevent him from leaving. It is said: The intent of "racing" on her part is that she followed him, but it was expressed this way for hyperbole. The door here is mentioned in the singular, despite its prior mention in the plural, because it refers to the outer door, which is the point of escape.
A difficulty has been raised: How could they race toward it when there were inner doors before it, based on reports that there were seven doors? It has been answered that it is narrated from Ka'b that the locks of those doors would scatter and open for him when Joseph, peace be upon him, approached them. It is also possible that those locked doors were not arranged in a sequence, one after the other, but were in different directions, all being exits for the space in which they were; thus, they raced to whichever door he might exit from.
The word "door" (al-baba) is in the accusative case due to ittisa’ (extension/ellipsis of the preposition), for the root of istabaqa (to race) is to be transitive with ila (to), but it appeared thus, following the pattern of "If they had weighed for them" (wa-idha kaluhum) and "And Moses chose for his people seventy men" (wa-khtara Musa qawmahu). It is also said that istabaqa was imbued with the meaning of ibtida’ (starting/proceeding), and thus it was rendered transitive.
(And she tore his shirt from the back): It is possible that this is conjoined to (raced), and it is possible that it is in the position of a hal (circumstantial accusative), as Abu Hayyan stated—meaning, "while she tore." The qadd (tearing) is cutting and slitting, and its most frequent usage is for length; this is the intended meaning here, based on the statement that she pulled him from behind, so the shirt tore down to its bottom. The qatt (cutting) is used for what is transverse. Upon this basis is the description of Ali—may Allah, the Exalted, honor his face—that when he rose, he would qadda (rip length-wise), and when he traversed, he would qutta (cut width-wise). It is said that qadd here is an absolute term for splitting; this is supported by what is reported from Ibn Atiyyah, that a group recited it as qatta (cut), and this was found in the Mushaf of al-Mufaddal ibn Harb.
From Ya'qub, the qadd is specified as that which occurs in skin and solid fabric. The "shirt" (qamis) is well-known, and its plurals are aqmisah, qumus, and qumsan. Attributing the tearing solely to her, despite the fact that the strength of Joseph, peace be upon him, also played a part in it, is either because she was the final part of the total cause, or to signal her exaggeration in preventing him from leaving and the exhaustion of her efforts in that regard due to the loss of the beloved or the fear of scandal.
(And they both found)—meaning they encountered (and Abdullah read it as such)—(her master), meaning her husband. It is a fi’al form from sada, yasudu (to lead/master), and it is commonly applied to an owner and a leader. It is said that at that time, a woman would say to her husband, "my master" (sayyidi), and this is why it did not say "their master." In al-Bahr, it is stated that it was not added to both of them because he was not the master of Joseph in reality, due to his [Joseph's] freedom.
(At the door), meaning at the outer door. It is said they found him wanting to enter with a cousin of hers.
(She said): This is an inauguration of speech based on the question of a querent who asks: What happened when they found the master at the door? It is said: She said, (What is the recompense of one who intended evil for your wife)—meaning adultery and the like—(except that he be imprisoned or a painful punishment?)
It is apparent that (ma) is negative, (jaza’) is the subject (mubtada’), and (man) is relative or qualifying, in the genitive case as an idafa. The interpreted masdar (the fact of his intending) is the predicate. The (aw) is for categorization, and what follows is conjoined to that masdar. That is: His recompense is nothing but prison or painful punishment. The intent of this, as is said, is whipping with a lash. From Ibn Abbas, it is related that it refers to shackles. It is also permitted that (ma) is interrogative, and jaza’ is either the subject or predicate, meaning: What is his recompense other than this or that?
She came in that state, which would bewilder even the most intelligent and astute person, where her husband witnessed her in that condition, using a trick in which she gathered two purposes: clearing her name from what was apparent in the outward situation, and breaking Joseph's resolve—peace be upon him—in his defiance and refusal to comply with her wishes, by casting terror into his heart from her cunning, in the hope that he would succumb to her forcibly when she despaired of him doing so willingly, as she said: (If he does not do what I order him, he will surely be imprisoned and will be among the humbled). Furthermore, she made the occurrence of the aforementioned intention from Joseph, peace be upon him, a confirmed and settled matter, needing no reporting of its happening, and that her actions were for the sake of realizing his [Joseph's] recompense. She did not state the name explicitly, but used a general expression to exaggerate the affair and increase the intimidation, as if this were a standard law for everyone, whoever they might be. She referred to herself as "your wife" to magnify the event and incite him to realize what he was aiming for under the influence of anger and protective jealousy.
This is how many have explained it. The Imam mentioned in his Tafsir that which contains a type of disagreement with this, as he said: There are subtle points in the verse: First, her intense love for Joseph, peace be upon him, led her to observe two niceties in this instance. She began by mentioning prison and delayed mentioning punishment, because a lover does not strive to cause pain to the beloved. Furthermore, she did not mention that Joseph, peace be upon him, must be met with one of these two things; rather, she mentioned it in a general manner to preserve the beloved from being mentioned with evil and pain. Also, she said: (Except that he be imprisoned), and the intent is that he be imprisoned for a day or less by way of mitigation; for perpetual imprisonment is not expressed with this phrase, but rather it is said: "He must be made one of the imprisoned." Do you not see how Pharaoh said, when he threatened Moses, peace be upon him: (If you take a god other than me, I will surely make you one of the imprisoned).
Second, when she witnessed from Joseph, peace be upon him, that he protected himself from her even though he was in the prime of youth, the perfection of strength, and the limit of desire, her conviction in his purity and innocence grew, and she was ashamed to say, "Joseph intended me with evil." She could not bring herself to accuse him with this lie explicitly, but sufficed with this allusion. Would that the literalists (al-hashwiyyah) sufficed with what she sufficed with! But they did not; they described him, nearly four thousand years later, with the vile things they described him with—and he is far above that.
Third, Joseph, peace be upon him, wanted to strike her and push her away from himself, and that, in relation to her, followed the course of "evil." Thus, her saying (What is the recompense), etc., runs in the course of allusion. Perhaps in her heart, she wanted him to proceed to push her away and prevent her, while in the outward appearance, she suggested that he intended her with what is not appropriate.
This is the end of the intended meaning, and it contains the views that it contains.
Zayd ibn Ali—may Allah the Exalted be pleased with both of them—recited (aw ‘adhaban aliman) in the accusative as a masdar (verbal noun), as al-Kisa'i stated, meaning: "Or he is punished with a painful punishment," except that it was omitted due to its clarity. This recitation is more in agreement with His saying, Exalted is He, (that he be imprisoned). The secret behind the difference in expression in the famous recitation has not appeared with anything that can be relied upon, and Allah the Exalted knows the secrets of His Book best. So reflect.