A man opened fire in a restaurant in a small town in southwest Germany on Tuesday, killing two people and injuring five others before taking his own life, police said.

Heidelberg police said a meeting of property owners was taking place in the restaurant in the town of Dossenheim, and there had reportedly been an argument shortly before the shooting.

"The exact context, the motives and the sequence of events are for the moment still unclear," a police spokesman told the DPA news agency.

Police were alerted at 7:00 pm (1700 GMT) and there were about 20 people in the restaurant at the time of the shooting in the town of about 13,000 inhabitants.

According to the initial police investigation, the man had been excluded from the meeting held in the restaurant, but returned with a gun and shot dead two men before turning the weapon on himself.

The shots also wounded five other people, some seriously.

"The witnesses are traumatised and in shock," a representative of the Heidelberg prosecutor's office told AFP.