The Tate Britain museum has bought Salisbury Cathedral from the Meadows by 19th century English painter John Constable for £23.1 million.
The painting, dated 1831, had been at risk of being sold abroad.
"Salisbury Cathedral from the Meadows is one of the great masterpieces of British art," Tate director Nicholas Serota said in a statement announcing the deal.
The landscape is one of a series of monumental canvases painted by Constable. It is considered the most visually spectacular of all his ''six footers'', and the one of which he was most proud.
Constable called it The Great Salisbury and wrote: "I am told I got it to look better than anything I have yet done".
The purchase was part of a new partnership linking five national and regional galleries, which will enable the work to go on almost constant view.