A historic New Hampshire mansion built by a wealthy industrialists has been saved from demolition by a last-minute sale to an art museum.

The Catholic Diocese of Manchester had applied for a permit in June to demolish Chandler House in Manchester after being unable to sell it. But a bid to save the 19th-century home by city and community leaders led to its sale to the Currier Museum of Art.

The museum plans to restore rooms on the main level of the house to their original appearance and conduct tours of those areas. The rest of the building will be renovated for office and classroom space.

“Obviously we are thrilled the house is being saved,” said Mayor Joyce Craig, who had sent a letter to the diocese this summer urging it to reconsider demolishing the structure.

“There is a lot of history there. Manchester is so proud of its history,” she said. “It is just gorgeous inside, the natural woodwork. It’s just critical to preserve a building, a structure such as this, so that generations going forward can enjoy it and appreciate it.”

The 30-room home was built by George Chandler, a banker and a philanthropist. More recently, the house was the home of several bishops in the city and a convent for nuns from the nearby St. Hedwig Church. It hadn’t been used for several years and had fallen into disrepair.

The diocese had been trying to sell the Victorian home for five years but had been unable to come to terms with a buyer. Keeping the building was not an option, the diocese said, because of the cost of maintaining it including a pricy heating bill.

Its decision to seek demolition of the home this summer angered historians, who have raved about its elaborate interior reflecting the peak of New Hampshire’s industrial past. Many rooms on the first floor have stained glass, and a stairway to the second floor features elaborate carved woodwork.

The move prompted Craig to write a letter to the diocese and generated an online petition. In the end, the diocese was able to come an agreement with Currier Museum, which owns two Frank Lloyd Wright-designed homes and is across from the Chandler House.

The museum was built on site of the Currier House, built by former Gov. Moody Currier.

“It seemed awfully wasteful to me. It was such a beautiful example of a house of its period,” Michael Duffy, a member of the Manchester Heritage Commission, said of plans to demolish the house. “This is one of the few remaining of big houses on big lots. Its location was really key to its significance.”

The sale price was not disclosed, and the museum still needs approval from the city to subdivide property.

“The Chandler House is a beautiful 19th-century residence that tells the story of New Hampshire’s dynamic past,” museum Director Alan Chong said in a written statement.

“The Currier Museum is proud to help preserve it for the benefit of the community in collaboration with the Diocese of Manchester, our long-time neighbors.”