Gender selection is possible through a procedure known as pre-implantation genetic diagnosis (PGD). Sex selection for social use is allowed in a small number of countries, though.
PGD is used for the genetic screening of the embryos before transferring them to ensure they are healthy, without chromosomal abnormalities, genetic disorders or birth defects.
It allows gender selection because the X and Y chromosomes have to be analyzed to dismiss the presence of sex chromosome abnormalities. At that point, the gender of each embryo (XX or XY) can be determined.
Suggested for you: What Is In Vitro Fertilization (IVF)? – Process, Cost & Success Rates.