MADRID — The Prado was not designed to be one of the world’s great art galleries. But as it celebrates its 200th anniversary this year, Spain’s national museum can boast of welcoming almost three million visitors a year to what has become one of Europe’s finest painting collections.

When King Charles III of Spain commissioned the building in the 1780s, he wanted a museum of natural science to celebrate the spirit of the Enlightenment. But when his ultraconservative grandson, Ferdinand VII, came to the throne three decades later, he put a stop to that. “He wanted to showcase the wealth of his collection rather than make any kind of contribution to scientific progress,” said Javier Portús, the curator of an exhibition that celebrates the Prado’s bicentenary.

“The irony is that the Prado opened in a period of clearly regressive thinking in Spain,” he added.

The exhibition, called “A Place of Memory” and running through March 10, shows how, right from the beginning, the Prado navigated the often choppy waters of Spanish politics, as the country went from being an imperial power to a nation divided by civil war, and then through dictatorship to the democracy it is today.