The mayor of the Libyan capital Tripoli was released hours after he was seized by gunmen, his family says.
Abdelraouf Beitelmal was taken from his home early on Thursday. He is said to be unharmed.
Sources close to his family told the BBC that the attackers had fired guns and struck his son with a rifle.
However the head of investigations at the general prosecutor's office told the BBC that the mayor had been taken into custody to be questioned.
The official, Sediq AlSour, gave no reasons for what he says was a legal arrest.
Government and militia forces have vied for power in Libya since the uprising in 2011.
The gunmen who seized Mr Beitelmal reportedly fired shots before entering his home shortly after midnight, the family sources said.
Later on Thursday Tripoli's municipal council blamed "a foolish party" for the operation, suspended work in protest.
Armed groups in Libya are known to threaten and attack government officials and civilians.
Moreover, it is often hard to assess the legality of an arrest because of the overlap between militias and government forces.
The country has been in chaos since the overthrow of longstanding ruler Muammar Gaddafi in 2011.