Britney Spears reveals a personal experience she has kept private for two decades in her upcoming memoir.

During her relationship with Justin Timberlake, Spears became pregnant by the singer and had an abortion, she writes in a book excerpt published by .

ā€œ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 her book, ā€œThe Woman in Me.ā€

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

CNN has not yet been able to independently review ā€œThe Woman in Me.ā€

A representative for Timberlake did not respond to CNNā€™s request for comment.

In the excerpt, Spears writes about how she felt conflicted at the time

ā€œIf it had been left up to me alone, I never would have done it,ā€ she writes. ā€œAnd yet Justin was so sure that he didnā€™t want to be a father.ā€

ā€œTo this day, itā€™s one of the most agonizing things I have ever experienced in my life,ā€ she adds.

Timberlake and Spears dated from 1999 until 2002.

Spears later married dancer Kevin Federline and had two sons, Sean Preston, 18, and Jayden James, 17, prior to her and Federline divorcing in 2007.

Timberlake married actress Jessica Biel in 2012 and the pair are the parents of two young sons, Silas and Phineas.

ā€œThe Woman in Meā€ publishes on Oct. 24.