Sophie Smith, 25, who was the childhood sweetheart of the Aston Villa player, admitted sending "insulting, harassing and degrading" messages to his new girlfriend Elizabeth Wheeler.
But a judge allowed her to walk from court after giving her a suspended sentence because she was pregnant.
He also issued a 10-year restraining order to stop Smith from going within 200 yards of Miss Wheeler's home.
Mr Agbonlahor, 25, met Miss Wheeler on holiday in Greece in 2006, and the pair have a four-year-old son together.
The court heard Smith had carried out a four-year campaign of abuse via emails and social networking sites.
Three quarters of stalking victims 'targeted online'
21 Feb 2012
Katherine Jenkins hits back at online stalker
14 Nov 2011
Agbonlahor to captain Villa
03 Apr 2012
She was ordered to pay £1,000 in compensation as well as being made the subject of a 12-month supervision order.
She will also have to take a 21-day domestic abuse course and any breach of the restraining order could carry a five-year prison sentence.
Sentencing Smith, District Judge Michael Morris said: "You subjected Elizabeth Wheeler to nearly four years of insulting, harassing and degrading messages.
"You made false and malicious comments which, at times, incited and caused great upset to Miss Wheeler.
"Your utilisation of Facebook over such a lengthy period of time can only be met by a prison sentence.
"However, in view of your present condition I am going to suspend that prison sentence."
As the verdict was read out, Miss Wheeler, who sat in the public gallery with friends, wept.
Michael O'Mahoney, defending, told the court Smith was sorry for what she had done.
He said: "This is a young lady who is pleasant, she is supportive of her friends and she greatly regrets her actions.
"She accepts that her behaviour went too far.
"There is, unfortunately, no love lost between my client and I believe in the early stages there were exchanges of unpleasantries between them.
"My client now accepts and is apologetic that she carried on the unpleasantries over a long period of time."
Miss Wheeler and Miss Smith declined to comment outside court.