You can usually claim an exemption for a dependent if he/she lives with you for the whole calendar year and you supported them for that year by providing food, clothes, medical expenses, etc. Other requirements dictate that the person should be a citizen or a resident of the US or Canada or Mexico for at least some part of the year. Also for them to qualify as a dependent they cant have a gross income of over $2750 a year unless he/she is your child and is under the age of 19 or if he/she is a student for the whole year and is under the age of 24, then they can have a gross income of over $2750 and you could still claim them for the exemption.
Under the special rule for custodial parent, the parent who has the child for most months of the year has the custody of the child for tax purposes. The custodial parent can then go ahead and claim an exemption for this child. This custody has to take place under a divorce agreement or a separation agreement, which clearly states which parent has the custody of the child and for how many months a year. If no agreements exist, the parent with whom the child lives as his/her home for the whole year is the custodial parent.
Non-custodial parent is the one who only has the child for a short period of time during the year. There are specific conditions that have to be met for the non-custodial parent to claim the exemption for the child. The custodial parent has to put in writing that he/she will not claim exemption for this child this year and the non-custodial parent can claim an exemption. This written note has to be attached to the non-custodial parents tax return. The other two conditions according to the IRS are:
If a decree or agreement was reached and signed after 1984 that states the non-custodial parent can claim the child as a dependent without regard to any other conditions, such as payment of support.
(Source: IRS web site)