The sex of a fetus is determined during fertilization. Fertilization is the process where a sperm cell from the male combines with an egg cell from the female to form a zygote, which develops into an embryo and eventually a fetus. The sperm cell carries either an X or Y chromosome, while the egg cell carries an X chromosome. If a sperm carrying an X chromosome fertilizes the egg, the resulting zygote will have two X chromosomes and develop into a female fetus. On the other hand, if a sperm carrying a Y chromosome fertilizes the egg, the resulting zygote will have one X and one Y chromosome and develop into a male fetus. Therefore, the sex of a fetus is determined by the combination of sex chromosomes from the sperm and egg during fertilization.