The story of how Charles Dickens helped save the house where William Shakespeare was born from the dastardly clutches of PT Barnum, the American showman who modestly billed his circus “the greatest show on earth”, will be celebrated in an exhibition at Stratford-upon-Avon this year.

The auction of the Tudor house was held in London on Thursday 16 September 1847, advertised by a poster announcing the sale of “the truly heart-stirring relic of a most glorious period and of ENGLAND’S IMMORTAL BARD ... the most honoured monument of the greatest genius that ever lived”.

Dickens first visited the house in 1838 when it was a private museum, signed the visitors’ book, and poured his love of the stage and Shakespeare into his account of the Crummles theatrical company in Nicholas Nickleby, which he began publishing as a serial later that year.

The poster advertising the sale of the house where Shakespeare was born. Photograph: The Shakespeare Birthplace Trust

Barnum visited six years later, and in 1846 when it was announced that the house would be sold, conceived a cunning plan: he would buy it anonymously, ship every brick and timber to the US, and reconstruct it as the star attraction of his museum of curiosities.

“I soon despatched a trusty agent to Stratford-on-Avon armed with cash and full powers to buy the Shakespeare house, if possible, and have it carefully taken down, packed in boxes and shipped to New York. He was cautioned not to mention my name, and to give no hint that the building was ever to leave England,” Barnum recalled in his autobiography.

But word of his plans got out. “British pride was touched and several English gentlemen interfered and purchased the premises for a Shakespeare Association,” he said. The birthplace would have been as great a sensation, Barnum reflected sadly, as when he snapped up Jumbo, the giant African elephant, from London zoo.

One of the interfering gentlemen was Dickens. Paul Edmondson, the head of research at the Shakespeare Birthplace Trust, which now owns the house in Warwickshire and a string of other properties associated with the bard, has traced the story of the sale through the archives, and found that despite ardent fundraising in London and Stratford-upon-Avon they were far short of their target with the sale fast approaching. Dickens threw himself into the campaign, organising readings and benefit performances of Shakespeare works, and almost doubled the fund.

It must have been a heart-stopping moment for the committee when bidding at the auction opened at 1,500 guineas, up to 2,000 in the next bid. The auctioneer was then informed that the committee could offer £3,000, the underbidder dropped out, and the house was saved.

The auction scene will be recreated at the house on the anniversary date next September, and a temporary exhibition will tell the story of Dickens and the sale which launched the Shakespeare Birthplace Trust. The trust’s five properties had a record year in 2016, the 400th anniversary of Shakespeare’s death, attracting 825,000 visitors.

If Barnum had managed to acquire the house, it would have been destroyed in 1868 when his museum burned to the ground. He incorporated many of its stars into a touring show which became the Barnum & Bailey circus: he died in 1891, and allegedly his last words were an inquiry about the previous night’s box office takings.