Jason Patric was just shut down by a judge in his bid to win paternity and custody rights over his son ... TMZ has learned.
Jason was locked in a bitter legal war with ex-GF Danielle Schreiber. The two were together for years but broke up in 2009. At the time they ended the relationship Jason told Danielle he didn't have any money to give her but he would give her his sperm, provided he had nothing to do with raising the child and she didn't ask for child support.
Danielle was artificially inseminated with the help of a doctor, and Gus was born in December, 2009.
Jason went away and had no contact with Gus, but came back in 2011. Jason and Danielle got back together ... but they broke up again. That's when he decided he wanted custody.
The trial has been going on for a week, and we've learned the judge just laid down the law -- a law that says if a man donates sperm to a woman to whom he is NOT married and she's inseminated with the help of a doctor ... the man has no paternity rights or claim of custody.
As we previously reported ... Danielle let Jason see Gus for visits, but there was no court order enforcing that. We don't know if she will continue to let Jason see the child.