When a woman conceives: In order to understand this verse it opens and says “We have learnt” in Tractate Niddah 31a, that for this purpose does the verse mention the matter of seed, to teach that if a woman emits seed first, she will give birth to a male child. [See Rashi, Parshas Bereishis 46:15]
Rabbi Acha said. He had a difficulty [in understanding a contradiction to the above verse] and said “But did we not learn,” in Midrash Tanchuma Parshas Pekudei 3, “that the Holy One Blessed be He decreed on that particular drop [of seed] if it will be male or if it will be female?” The Holy One Blessed be He decrees on that drop [of seed] that is released at the time of unification [between husband and wife], if it will be male or if it will be female. “And you say,” and how can you say “a woman who emits seed first gives birth to a male?” The implication is that [determination of the sex of the child] is dependent upon the seed of the man or the woman, and not the decree of the Holy One Blessed be He.
Rabbi Yosi said. He answered Rabbi Acha and said “Certainly, the Holy One Blessed be He distinguishes between the male drop and the female drop.” And the angel is not able to distinguish [this.] Therefore he [the angel] asks about this drop concerning what will be of it. “And since He distinguishes it,” and sees who emitted seed first, “He decrees upon it if it should be male or female.” Since only the Holy One Blessed be He knows how to distinguish who seeded first, and therefore afterwards He decrees if it will be a male or a female.
The intention of the answer is as written in Parshas Terumah 161b, that the soul stands in its image in a treasure-house. And when the time comes for it to come down into this world, then the Holy One Blessed be He commands the angel appointed over the soul “Go and bring Me the soul of so-and-so.” And as it is, the drops of seed of the male and female are joined together, and the angel does not have the strength [ability] to know who emitted seed first. Only the Holy One Blessed be He knows how to distinguish. Therefore He decrees and says “Go, bring Me this soul.” And everything is in accordance with the preparation of those below in this world.
[The angel lacks the ability to know the sex of the soul to be born. The sex is actually determined by our service below, but G-d Himself distinguishes between the seed to make the final decree. This decree is told to the angel who then continues its mission.]
NOTES TO FORMATTING:
BOLD PRINT - ORIGINAL ZOHAR
ORDINARY PRINT: MATOK MIDVASH
[ITALICS AND SQUARE BRACKETS] - ELIYAHU BEN PINCHAS
(ROUND BRACKETS): Either the source being quoted e.g. Proverbs etc., or alternatively used to quote the kabbalistic language as discussed in Matok Midvash. The Matok Midvash formats the Nigleh side of things in an ordinary print, and the Nistar terminology in Rashi script. I’ve therefore put the Rashi script – the Nistar terminology in round brackets.