Riot police surrounded the apartment of the suspected killer in the evening and arrested him, the statement said, without providing a motive or further details.
Basel police were looking for witnesses.
The killings took place between 2 and 5pm in the Breitequartiers neighbourhood of the city.
The incidents came just hours after three bodies were discovered in the Bernese Oberland village of Wilderswil in what appeared to be a murder-suicide.
One woman and two men had been killed in the shooting near the train station, police said.
“Initial elements indicate that this is a relationship-related crime, and the suspected shooter is one of the two men who died,” Bern cantonal police said in a statement.
Media reported that two men and one woman, all Portuguese citizens, had been killed in a jealousy drama.