The 38-year-old man, originally from Cameroon, holed up in the second-floor apartment of his former girlfriend in the Praz-Séchaud neighbourhood, according to media reports.
Police said he was armed with a gun and 20 cartridges.
Officers organized the evacuation of 22 residents from two apartment buildings after members of the man’s family alerted authorities at around 12.40pm, the ATS news agency reported.
According to a neighbour, the man threatened to “take potshots at anything that moved”, 24 Heures, the Lausanne newspaper, reported online.
Specialists from the Lausanne police force, including trained negotiators, as well as fire fighters and ambulance attendants arrived at the residence.
But the man refused to negotiate with police.
The standoff continued for more than 11 hours.
Police said the man threatened to commit suicide.
An officer finally used a Taser to subdue the man, without injuring him, before he was detained, police said.
A Swiss woman living nearby said she heard a “boom” sound then saw the man being taken out of the building in a stretcher at around 11.50pm, 20 Minutes reported.
Sylvain Jacot-Descombes, spokeswoman for the city police force, told ATS that he was taken to hospital “for a check”.
No shots were fired and no-one was injured, she said.
The local prosecutor's office has launched a criminal investigation into the case.