The gender in humans and most other mammals is determined at the time of conception. What your baby’s gender would be entirely depends on what pair of sex chromosomes it gets. Simply, boys have a pair of two different chromosomes – XY and girls have two X chromosomes – XX.
The mother can only provide a X chromosome, the Y chromosome can come only from the father. In other words all eggs contain one X chromosome, while 50% of spermatozoons have X and the other 50% have Y chromosome. During fertilization only one spermatozoon fertilizes the egg and depending on the sex chromosome it carries (X or Y), the gender of your baby is formed.
Humans have a gene or genes on the Y-chromosome that determine maleness. A single gene (SRY) on the Y-chromosome acts as a signal to set the developmental pathway towards maleness, but not all male-specific genes are located on the Y-chromosome.
A lot can be written about sex determination in humans, these are only the very basic things. When we have some more time, we will provide some more cool and interesting information about this. Fortunately, Interner is full of information and if you need more, we would recommend you start form here: http://en.wikipedia.org/wiki/XY_sex-determination_system
You can also have a look here: http://www.nature.com/scitable/topicpage/the-sex-of-offspring-is-determined-by-6524953