An armed gang staged a terrifying gunpoint raid after forcing their way into a flat have been jailed.

The four balaclava-clad intruders carried a handgun, a crowbar and a machete as they burst into the Fife home of Dwayne Kinner, who was with his cousin Nicholas Roberts, known as Ollie.

The High Court in Edinburgh heard the victims believed they were going to be shot after the gun was pointed at their heads and another robber threatened he was going to cut their fingers off.

James Mackie, 30, Gordon Ellis, 24, Derek Finlay, 31, and Scott Smith, 23, made off with a haul of £2500 and other valuables following the robbery at the flat in Viceroy Street, Kirkcaldy, in January 2015.

Sentencing on Thursday, Michael O'Grady QC told the robbers: "You have pled guilty to an extremely serious offence.

"In a premeditated and carefully planned enterprise, with a chosen victim, you armed yourself with weapons some potentially lethal."

The judge added: "The idea that anyone should suffer such terror in their own home is utterly beyond the pale."

He told Mackie and Finlay, who both have lengthy criminal records, that it was clear that they played the major role in the offence and jailed each of them for six and a half years.

Mr O'Grady sentenced Ellis and Smith to four years in prison each and said: "It is clear your roles in the attack were lesser ones."

Among the items taken in the raid was a mobile phone on which Mr Kinner had installed a tracking app in case it was lost or stolen.

Hours later he arrived at Kirkcaldy police station with a tablet containing a screenshot showing that in the early hours of January 8 his Sony Experia phone was at a house on Stewart Street in Dysart.

The High Court in Edinburgh heard that following the raid Mackie gave a woman a gold watch and asked her to keep it for him.

She threw it away in a panic but took police to the area and the watch was recovered.

The gun, which was found to be an air pistol, was later found behind a kickboard in a kitchen at a house in Glenrothes which Finlay had previously had access to.

Advocate Ashley Edwards QC said it had the appearance of a firearm.

The court heard that Mr Kinner and Mr Roberts, who was 23 at the time, had spent the evening of January 7 watching TV and playing computer games when shortly before midnight they heard sounds as though the front door was being kicked in.

Mr Roberts went into the hall and was confronted by the four masked men.

Finlay was holding the gun and asked: "Where's the money?"

The victims were continually asked where valuables were in the flat and cable ties on the TV were cut with a machete to allow it to be removed.

After the intruders left the victims discovered that Mr Kinner's bedroom had been ransacked.

Ellis was later detained by police in Kirkcaldy and admitted he was involved in the robbery. He said three or four days before it Mackie, who knew he was in a lot of debt, had spoken to him.

He said: "Mackie phoned me and said there was a job going if I wanted it."

He said that after the raid they went back to Finlay's house and split the cash.

Police also learned that following the robbery Smith and Mackie had been boasting that they had just "taxed Ollie".

Smith was later interviewed by police and said: "Four of us went in. I only had a crowbar."

He said Mackie had said he had "a job" to do and there would be money in it. He said the victims seemed to be scared.

Mackie, of Denfield Place, Kirkcaldy; Ellis, of Mains Road, Cardenden; Finlay, a prisoner, and Smith, of Kirkburn Drive, Cardenden, all earlier pled guilty to assaulting and robbing the victims.