A psychiatric patient who was travelling back from hospital robbed the taxi driver sent to collect him.
Jamie Stanger demanded cash and three times tried to punch his victim in the face.
He snatched around £42, as well as a phone used to provide the driver with sat nav information.
Preston Crown Court court heard how the driver shouted for help and passers-by came to his aid, helping him get most of the money back.
Stanger, 24, of Hornby Road, central Blackpool, who had pleaded guilty to robbery, was sentenced to two years in prison for the offences.
The court heard on May 19 Chorley District and General hospital had arranged for a taxi to collect him from a ward there and he asked to be taken to Blackpool.
Jeremy Grout-Smith, prosecuting, said when the driver got to Blackpool the defendant gave a number of instructions, believed to have been a tactic to confuse and disorientate the driver.
Stanger asked him to stop on Gloucester Avenue, before taking off his seat belt, turning to the 30-year-old driver and demanding money.
He then snatched £42 from the central console of the cab.
Mr Grout-Smith said: “He took the money and raised his left arm with a clenched fist at the same time. He said, ‘give me the money or I’ll punch you’.”
Stanger went on to demand the sat nav. He took that and also demanded an iPhone.
The defendant tried to punch him three times in the face, but the driver managed to avoid the blows before jumping out of the taxi and shouting for help.
A group of men nearby helped chase Stanger while the driver grabbed his jacket and grappled with him. Others helped him get most of his money back.
Stanger was detained when police went to the outpatients department of Blackpool Victoria Hospital.
Julie Taylor, defending, said the robbery had not been pre-planned.
“He did not call a taxi simply to commit a robbery. It was an intention formed during the journey.
“The defendant had been discharged from the psychiatric unit and was suffering from some sort of illness, but doesn’t put that forward as a defence or an excuse.
“When the police went to the hospital he immediately held out his hands to be handcuffed. He co-operated fully”.
Judge Heather Lloyd, who considered psychiatric and probation reports on Stanger, said the taxi driver had only been doing his honest day’s work.
Stanger’s mental health problems were associated with using alcohol, cannabis and cocaine.
She told him: “A doctor felt you were having a mild depressive illness at the time. Plenty of people have that and they don’t rob people.
“You must know taxi drivers are vulnerable people.
They will be protected by deterrent sentences if that is appropriate”.