Britney Spears claims in memoir she had an abortion while dating Justin Timberlake

Spears' upcoming memoir, "The Woman in Me," comes out on Oct. 24.

Britney Spears says in her highly anticipated upcoming memoir that she had an abortion while she was dating ex Justin Timberlake.

In an excerpt from Spears' book, "The Woman in Me," shared with People, Spears claims that when the two were dating, she became pregnant with his baby but ended the pregnancy because she said he felt they "weren't ready."

"It was a surprise, but for me, it wasn't a tragedy. I loved Justin so much. I always expected us to have a family together one day. This would just be much earlier than I'd anticipated," Spears writes in the memoir, discussing when she found out that they were expecting.

"But Justin definitely wasn't happy about the pregnancy," she writes. "He said we weren't ready to have a baby in our lives, that we were way too young."

The former couple first started dating in the late '90s and broke up in 2002.

Spears continues, "I'm sure people will hate me for this, but I agreed not to have the baby. I don't know if that was the right decision. If it had been left up to me alone, I never would have done it. And yet Justin was so sure that he didn't want to be a father."

Of the abortion itself, Spears writes, "To this day, it's one of the most agonizing things I have ever experienced in my life."

"GMA" reached out to Spears' and Timberlake's teams for comment but did not immediately receive a response.

Spears eventually went on to welcome two sons -- Sean Preston and Jayden James -- with ex-husband Kevin Federline. Timberlake has two sons, Silas and Phineas, with wife Jessica Biel.

Spears' memoir, "The Woman In Me," is described as "a brave and astonishingly moving story about freedom, fame, motherhood, survival, faith and hope," according to publisher Gallery Books.

Gallery Books says the memoir "reveals for the first time [Spears'] incredible journey -- and the strength at the core of one of the greatest performers in pop music history," and that it "illuminates the enduring power of music and love -- and the importance of a woman telling her own story, on her own terms, at last. "

"The Woman in Me" will be released on Oct. 24.