My nephew, by marriage, lived with me for 8 months. Mom signed/ notarized a temporary custody. She claimed him as a dependent. Is that legal and can I still claim him as a dependent?

I financially supported him for those 8 months but mom claims that she is the custodial parent and has the right to claim him.