As the former Formula 1 group chief executive, 91, boarded a private plane for Switzerland on Wednesday evening, local officials said.
They found an undocumented LW Seecamp .32 pistol in Ecclestone’s luggage during an X-ray check, police said in a statement.
Ecclestone was then arrested and taken to a facility at Viracopos Airport in Campinas.
The Briton admitted to possessing the weapon, but said he did not know it was in his luggage at the time, police said.
He paid his bail and he was released to go to Switzerland.
Ecclestone is married to Fabiana Ecclestone, of Brazilian origin, vice-president of the FIA and member of the World Motor Sport Council.
They attended several events in the South American country in May, including a local Stock Car race in the countryside near Sao Paulo and a meeting with three-time world champion Nelson Piquet in Brasilia.
Standard has contacted Ecclestone representatives for further comment.