"I will try to give my best as a player if I get the opportunity."
Mashrafe had not played any one-day internationals since last year's World Cup until the current Zimbabwe series. He claimed three wickets in the first two matches.
Bangladesh won both to take an unassailable 2-0 lead in the series. Mashrafe, who withdrew from a lucrative national team contract in January, said the decision to rebuild the team for the next World Cup had convinced him to step down.
"Until yesterday I was undecided, but this morning I thought 'that's enough'," he said.
Mashrafe, who has had seven operations on his knees, acknowledged that he had been lucky to play so long.
The bowler has cult status in Bangladesh for his role in taking the team from being international whipping boys to becoming a respected limited-overs side.
He led Bangladesh to 49 wins in 87 matches, making him Bangladesh's most successful one-day captain.
Mashrafe also led Bangladesh to 10 Twenty20 wins before retiring from the format in 2017. He has not played a Test since 2009 due to injury.
Mashrafe won a seat in parliament for the ruling Awami League party in an election in December 2018. The Bangladesh board wanted to organise a grand farewell last year, but Mashrafe rejected the offer.