Ba, a former Senegal international won the Europa League with Chelsea in 2013 and twice won the Turkish title, first with Besiktas in 2016-17 and then Istanbul Basaksehir in 2019-20.
He was without a club after walking out on Swiss side Lugano in August.
He wrote on his Twitter handle:”What a wonderful journey it has been. Football has given me so many beautiful emotions.”
He scored seven goals in 13 appearances for the Hammers before moving to Newcastle six months later.
For Newcastle he netted 29 times in 57 games, joining Chelsea in January 2013 where he started just 23 of his 51 games for the Blue – scoring 14 goals – as he found himself third choice behind Samuel Eto’o and Fernando Torres.
In between stints playing in Turkey he also played in China for Shanghai Shenhua.