The shooter, believed to have a personal motive, launched an assault in the town of Rot am See.
Police in nearby Aalen told AFP a man with a personal connection to the victims had been arrested and there was no indication that other gunmen were involved.
The police told local TV that the suspect was a German.
After the shooting at around 12:45 (1145 GMT), police arrived on the scene to find the dead and wounded in and around a local hotel.
The Bild newspaper reported that the people killed were family members of the shooter, adding that the perpetrator was a man born in 1983.
Jews demand action from Germany after deadly anti-Semitic attack
Police were unable to confirm details of the relationships or the identity of the shooter.
The shooting took place near the train station at Rot am See, a town of 5,200 residents near Heidelberg.
Aalen police urged people to "refrain from speculation" about the shootings in a message on Twitter.
Police and prosecutors said they would provide more details about the attack in a press conference in Rot am See later on Friday.
While owning firearms is not illegal in Germany, most guns can be acquired only with a licence and they are closely monitored, making mass shootings comparatively rare.
In October last year, a far-right attacker shot two people dead in eastern city Halle and wounded several more after failing to break into a packed synagogue armed with home-made weapons.
In July 2016, a teenager used a pistol bought illegally online to kill nine people in a Munich shopping centre before turning the weapon on himself.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ