A man has fought back after a man with a gun attempted to carjack him at a service station, beating him away with a jar of coffee.

A man has told of how he saw off a violent attacker allegedly trying to rob him and steal his car at a service station in Frankston on Tuesday night, by hitting him with a jar of coffee.

Jason, 48, was walking to his vehicle after buying cigarettes and coffee — a jar of Nescafe Blend 43 — on Tuesday night, according to 7 News. But as he neared his car, a Mercedes Benz, he was approached by an unknown man about 9.40pm. The man was allegedly armed with a firearm which he pointed in Jason’s face, demanding his keys.

“I sort of stepped back and said, ‘No, you’re not getting my keys’,” Jason told 7 News. He used the only thing he had on hand — a jar of instant coffee.

“When I kicked him, he struck me on the head with the firearm,” Jason said.

But Jason said despite being threatened, he refused to give the man his keys, and the unknown man eventually fled after stealing Jason’s cigarettes.

“I think most people probably should hand the keys over, but I’m sort of not one of those people,” Jason said.

The alleged attacker took off in a waiting car, a brown VT Commodore, which had no number plates, according to Victoria Police.

Jason suffered a minor injury on his forehead from the attack, which didn’t require treatment.

Police are investigating the incident. They believe the attacker to be caucasian, in his 20s, of a slim build, about 183cm tall. He was wearing a grey top, black bum bag, red underpants and possibly a white T-shirt with black pants, black and white sneakers and a maroon beanie with ear warmers.

Anyone with information is urged to contact Crime Stoppers.

A story emerged yesterday of two mates fending off three teenage home invaders, after the group allegedly attempted to steal a car from their driveway in Keilor, Melbourne.

Three suspects have been arrested in connection with the Keilor incident, and there is no indication the two attempted carjackings are connected.