The 77-year-old retired farmer lives alone in his isolated rural cottage at Aughabrack near Dunamanagh.
Neighbours heard him calling for help at about 20:00 GMT on Sunday.
Two men rushed to help and used their car to block the gang's vehicle. As they approached, three men came running out, their faces masked by scarves.
"All I saw was the barrel of the shotgun being pointed at us. One of the gang was shouting; 'Shoot them, shoot them'," one of the neighbours said.
As the men withdrew, the gang managed to escape. The two neighbours gave chase before losing them on country roads.
They returned to the house to find the elderly farmer badly shaken.
It is understood he suffered serious burns to his arm when he tried to throw boiling water at his assailants. He had also been threatened with a knife.
It's understood the shotgun used by the gang to threaten the neighbours belonged to the farmer. It was loaded.
The pensioner is staying with relatives.
Police are seeking information about a Seat car used by the gang. A Seat Toledo car CKZ 8800 was found burnt out at Daisyfield Park off the Letterkenny Road, Londonderry early on Monday.
SDLP councillor Patsy Kelly described the gang who carried out the attack were "cowards".

The former first lady and widow of former President Hafez al-Assad died in hospital, the presidency tweeted.
Reports say she was ill for many years and travelled frequently to Germany for treatment before 2012, when she was blacklisted by the EU.
Marrying Hafez in 1957, she had five children, three of them still alive.
The rise of the Assads
She was born into a wealthy family from Syria's Alawite minority from Latakia and rarely appeared in public after her marriage.
However, she is believed to have stayed close to Bashar and the other children.
She was later reported to have left Syria to join her daughter Bushra in the United Arab Emirates.
Bushra moved there after a bomb killed her husband, Deputy Defence Minister Assef Shawkat, in 2012.
Mrs Assad is survived by Bashar, Bushra and Bashar's younger brother Maher, a general in the Syrian army.
Bashar's older brother Bassel, who had been groomed to take over the presidency, died in a car accident in 1994. The other brother, Majd, died of an unspecified illness in 2009, according to state media.
A gang of men who assaulted a County Tyrone pensioner during a robbery threatened to shoot two neighbours who came to his aid.
[NEXT_CONCEPT]
The mother of Syrian President Bashar al-Assad, Anisa, has died at the age of 86 in the capital Damascus, his office announced.