A judge has ruled in favor of Sofia Vergara regarding custody rights of frozen pre-embryos against her ex, Nick Loeb.

The pre-embryos were created while the two actors were together, and a custody battle has ensued since their split.

Vergara, now 48, filed legal documents in 2017 hoping to block Loeb, now 45, from being able to use the embryos without her consent.

On Tuesday, a Los Angeles court granted the "Modern Family" alum a Permanent Injunction, blocking Loeb from creating "a child without the explicit written permission of the other person," according to court docs obtained by People magazine.

SOFIA VERGARA WINS COURT BATTLE AGAINST EX NICK LOEB OVER FROZEN EMBRYOS

Sofia Vergara (left) has won a court battle against her ex, Nick Loeb (right), over frozen pre-embryos made by the two before their split.

Sofia Vergara (left) has won a court battle against her ex, Nick Loeb (right), over frozen pre-embryos made by the two before their split. (Getty Images)

Reps for Vergara did not immediately respond to Fox News' request for comment.

"The judge was clearly influenced by Hollywood, which is a pattern I expose in my upcoming film Roe v. Wade on April 2nd," Loeb said in a statement to Fox News. "It’s sad that Sofia, a devout Catholic, would intentionally create babies just to kill them."

Court records indicate that the pair had previously signed a document at the fertility clinic stating that both Loeb and Vergara had to consent to the use of the embryos, the outlet reports.

SOFIA VERGARA SHARES THROWBACK GOLDEN GLOBES' PHOTOS

Loeb claimed that he signed the document under "duress," but the court determined that the form "is not void or voidable based on Defendant Loeb's duress defense as to its execution."

He also previously claimed that he and Vergara had an "oral agreement" regarding the use of the pre-embryos, but the court found no "material fact" supporting that claim.

Sofia Vergara has successfully blocked her pre-embryos from being used without her written consent. (Photo by Tony Barson/FilmMagic)

Sofia Vergara has successfully blocked her pre-embryos from being used without her written consent. (Photo by Tony Barson/FilmMagic)

Loeb has also tried to obtain custody of the embryos through the Louisana court, though the case was dismissed in January.

CLICK HERE TO GET THE FOX NEWS APP

In early February, Loeb told Fox News that he planned to appeal the court's ruling in favor of Vergara and that he is focused on releasing the film "Roe v. Wade," which he co-wrote and directed.

CLICK HERE TO SIGN UP FOR OUR ENTERTAINMENT NEWSLETTER

Vergara is now married to actor Joe Manganiello, whom she wed in late 2015. She has a 28-year-old son, Manolo, from a previous relationship.