Mr Bongo, 73, died at the Quiron clinic in Barcelona, according to a statement issued at the hospital by Jean Eyeghe Ndong, Gabon's prime minister.
"Throughout his political career, President Bongo always cultivated unity and cohesion among the Gabonese people," Mr Ndong said, announcing 30 days of national mourning.
Mr Bongo, who was believed to be one of the world's wealthiest leaders, became the longest-ruling head of government – a category that does not include the Queen or the Thai king – when Cuba's Fidel Castro handed power to his brother last year.
Mr Bongo has ruled the nation of 1.4 million people since 1967 and is seen as the one man who can keep it stable, despite widespread concerns over corruption.
Bars in Gabon's capital, Libreville, immediately closed after Sunday's reports of his death and queues formed at petrol stations as people began panic-buying emergency supplies.
Mr Gabon is under investigation by French authorities over allegations that he plundered state resources to pay for huge houses and luxury cars in France.