The local council rejected Mr Doonan's housing plans
Campaigners hoping to save the historic Crook Inn at Tweedsmuir have been given the right-to-buy the property.
Scottish Government ministers have granted the Tweedsmuir Community Company right-to-buy status on the pub, one of Scotland's oldest hostelries.
But the group will have to await the outcome of a planning appeal by the current owner before it can plan to reopen the 17th Century coaching inn.
James Doonan bought the pub nearly two years ago and closed it within months.
The businessman bought the property in 2006, at a cost of £350,000.
His bid to convert the building into flats was finally rejected by local councillors on Tweeddale Area Committee in March, but he has now appealed the decision.
A hearing will take place within the next few months.
Right-to-buy allows the campaign group first refusal on the inn, at a independently valued price, whenever it is put up for sale.
Andrew Mason, vice chairman of the group, said: "We are delighted, the volunteers put an awful lot of effort in over the past two years and it really brought the community together.
"The Crook Inn is so much more than a pub, it's a community hub with a rich history that has always been part of people's lives here.
"This decision validates our argument that turning it into flats was symptomatic of a decline in the rural way of life - we've lost our post office, our local shop, our school - and rural pubs are an easy target for property developers."
He said there should be legislation in place to protect "rural lifelines".
A letter from the Scottish Government informed the group of the decision.
It said the inn had fulfilled a vital role as the hub of the community for more than 400 years.
It added that reinstating it would serve the public interest by allowing the development of exciting and interesting community initiatives in a rural area.
Mr Mason said there were big plans for the Crook Inn, if the buyout goes ahead.
He said: "The pub hasn't been open for about a year so it will need a bit of work.
"But we want to make it a hub for community activities, with things like GP and dentist's surgeries there one afternoon a week.
"Hopefully, there will be good potential for funding - it's a very exciting time."
The inn dates back to 1604 and was said to be the haunt of writers like Robert Burns and Sir Walter Scott.