A 47-year-old gunman has shot and killed two people and injured another in a rampage in Germany before being overpowered by two garage mechanics, authorities said.

Officials said the victims appeared to have been chosen randomly by the suspect, who spoke "incoherently" after his arrest in the southern state of Bavaria.

"At the moment there are no indications of any immediate relationships between the culprit and the victims," said Bavaria's interior minister Joachim Herrmann, who called it an "ugly, incomprehensible crime".

Police were alerted at 10am that a middle-aged man driving a silver Mercedes had opened fire on a woman in the town of Tiefenthal, 30 miles west of Nuremberg. The 82-year-old woman died at the scene.

Shortly afterward, the gunman fatally shot a 72-year-old man riding a bicycle in the nearby town of Rammersdorf. A driver who was threatened by the suspect gave details of the man's car to police.

The suspect then fired at a farmer driving a tractor, who was slightly injured by flying glass, and drove to a filling station in Bad Windsheim, 20 miles from the scene of the shootings.

"Shortly before noon, police were informed that staff at an Esso gas station in Bad Windsheim had overpowered the man after he threatened them with a weapon," said Mr Herrmann. "It's thanks to the brave intervention of the gas station staff that the suspect was stopped."

Prosecutors said the suspect, a local man identified only as Bernd G in line with German privacy rules, showed signs of psychological problems and was being assessed by a psychiatrist.

He had no previous convictions, prosecutor Gerhard Neuhof said.

The man had permits to own two firearms but not to carry or use them, authorities said.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.