The 32-year-old moved to the Rec in 2003 and has made 161 appearances for the club.
Flatman also won eight England caps but his career has been blighted by injuries and he has now decided to call it a day, instead taking up a backroom role with Bath.
"It's been a difficult decision to make, but you have to listen to medical experts when they tell you it's time to stop," he said on www.bathrugby.com.
"Naturally, it's tough coming to terms with this, but the club have been fantastic in their support.
"I have truly loved my time as a Bath player and would like to thank all the players, coaches, staff and supporters who have made it so enjoyable.
"I've forged memories and friendships that will last a lifetime and feel incredibly proud to have worn the jersey.
"I'm looking forward to staying with Bath in what I have no doubt will be a challenging but exciting new role."