The 33-year-old's contract was due to expire this summer but the Reds have reached an agreement with him over the remaining five months on his deal so he can return to his homeland.
Doni has not figured for the Reds since the final day of last season at Swansea City.
He made just four first-team appearances for the club after moving to Anfield for around £1.3million from AS Roma in July 2011.
Botafogo SP club president Gustavo Assed told Globo Esporte: "We made an offer for him, as the player himself asked. We understand Liverpool have accepted the offer, so we are planning to officially unveil him this Friday.
"Doni wants to finish his career at Botafogo, he is a top quality national team level goalkeeper. Most importantly, he is a Botafogo fan and we wanted him".