Sofia Vergara is embroiled in a court battle with her ex-fiancé Nick Loeb over two frozen female embryos they had conceived in hopes of starting a family when they were together.

In bombshell court papers filed by Loeb under the name “John Doe,” he is seeking to prevent the actress, named as “Jane Doe,” from destroying the embryos they had saved for surrogacy. But the couple split in May 2014 after failing to conceive.

Page Six has confirmed that the anonymous California filing, first revealed by In Touch, has been made by Loeb against Vergara, 42. The papers state John Doe (Loeb) “seeks to ensure that the Female Embryos are not destroyed, but Jane Doe [Vergara] refuses to agree to their preservation under all circumstances.”

At the end of the relationship, “John attempted to get Jane to agree that, if one of the parties should die, the other party should control the Female Embryos. Jane refused to even respond to this request, apparently because she hoped for the female embryos to ultimately be destroyed.”

The lawsuit also accuses Jane (Vergara) of being abusive during their four-year relationship, saying she was “on many occasions, physically, emotionally and mentally abusive to John.” Court papers allege Jane “punched him in the face on two occasions, kicked him, and threw her phone at his head.”

She also routinely bullied him, calling him a “loser” and “worthless.”

A source tells Page Six: “This is a complaint filed by Nick to stop Sofia from destroying the two female embryos. Nick filed as John Doe because he wanted to do it anonymously. They had agreed to freeze the embryos when they were together because Sofia didn’t want to carry another child, she wanted to do it via surrogate. But two attempts failed.”

The source continued: “If either of them dies, the other has the right to destroy the embryos. But Nick believes life begins at conception, that life is life, it is horrible to keep them frozen, these are his babies. He hopes the filing will be a test case for how frozen embryos should be handled.”

Another source defended Vergara, who’s now engaged to “True Blood” actor Joe Manganiello, telling us: “This is a desperate attempt for attention. Why would he claim that she was abusive to him and still want to have children with her? She is engaged to someone else. He is perfectly fertile and could go and start a family with another woman. This is a sad attempt to stay relevant and hold onto the past and her.”