Sofia Vergara has scored a win in court.

The "Modern Family" alum beat out her ex-fiance Nick Loeb in a battle over custody right to frozen embryos.

According to online documents, while they were still together the pair underwent in vitro fertilization treatment in an attempt to impregnate a surrogate. The first attempt failed and upon a second attempt, they consented to a "Directive for Partners Regarding the Storage and Disposition of CryoPreserved Materials Which May Include Embryos."

The directive offered options for procedures should either Vergara, now 48, or Leob, now 45, pass away the embryos would be donated to science, thawed, or given to the remaining partner. The docs state that Loeb claimed Vergara "forced him to choose" they be thawed.

SOFIA VERGARA WOWS FANS WITH THROWBACK BIKINI SNAPS

Sofia Vergara (right) has won a legal battle against ex Nick Loeb (left) over custody of frozen embryos.

Come the spring of 2014, the couple broke up, though they disagree on when the relationship came to an end. While Loeb claims he tried to talk to the actress about the embryos, she claims he didn't speak of them until September.

The two battled in court over what would come of the embryos and in 2017, Vergara filed a suit hoping to block Loeb from using the embryos without her consent, though the docs indicate the matter is still undecided, according to People magazine.

SOFIA VERGARA STUNS IN THROWBACK BIKINI PIC FROM THE '90S

Loeb's suit seeking to obtain custody over the embryos was dismissed before that, and he's continued to seek custody, though his most recent attempt in Louisana was dismissed.

Sofia Vergara (left) and Nick Leob (right) had embryos developed when they were in a relationship. The relationship has since ended. (Getty Images)

According to the docs, the court found that the actor "is not domiciled in, does not maintain a residence in, and does not have the intent to be domiciled or a resident of any parish in the State of Louisiana." He was also accused of "forum shopping" by trying to find a court that would award him custody though outside proper jurisdiction.

CLICK HERE TO GET THE FOX NEWS APP

"Furthermore, based on all of the facts ascertained through the deposition testimony, exhibits, affidavits and allegations contained in Appellant's petition and first amended complaint, it is clear that Mr. Loeb blatantly engaged in forum shopping when he selected, in concert with a member of the bar ... Plaquemines Parish to file the instant lawsuit, with full knowledge that it was the improper venue," the docs say. "Their behavior brings disrepute to and makes a mockery of the Louisiana legal system and the bar and is abhorrent."

CLICK HERE TO SIGN UP FOR OUR ENTERTAINMENT NEWSLETTER

Loeb told Fox News that while he is focused on releasing the film "Roe v. Wade," which he co-wrote and directed, he and his team "are appealing" the court's decision. A rep for Vergara did not immediately respond to Fox News' request for comment.