Abdel Majid Touil, 22, was arrested on an international warrant by Italy's anti-terrorism Digos police in the northern town of Gaggiano, officers told a press conference.
Touil, who is wanted for premeditated murder, kidnapping and terrorism, was detained on Monday evening. He was living with his mother, a carer, and two older brothers in the town near Milan.
The Bardo attack on March 18th killed 22 people, including a Tunisian policeman and tourists from Italy, Japan, France, Spain, Colombia, Australia, Britain, Belgium, Poland and Russia.
Tourists getting off buses outside the museum were gunned down by two black-clad gunmen with automatic weapons, who then took hostages inside the building.
Many people were shot in the back as they tried to escape. After rampaging through the museum for several hours, the two gunmen were killed in an assault by security forces.
Tunisia's President Beji Caid Essebsi said a few days after the attack that a third gunman was on the run.
Police said Touil had been in Italy before the attack. They said he entered illegally in February with a boatload of 90 migrants, before being issued with an order to leave.
The officers did not specify whether he had been expelled or, if he had, where he had gone to.
They said investigators had been able to trace Touil because his mother had reported his passport missing.
'Close the borders'
The news that the suspect had snuck into Italy by boat sparked an immediate outcry among right-wing politicians, with the head of the anti-immigration Northern League party, Matteo Salvini, calling for the Schengen agreement allowing free movement between most continental European states to be suspended.
“Libyan intelligence says boats are arriving with Islamic State terrorists.
Today in my Milan a North African was arrested for involvement in the Tunisian massacre. Close the borders before it's too late,” Salvini told Italian media.
Hard-right politician Daniela Santanche from Silvio Berlusconi's Go Italy party also slammed the government.
It is “unbelievable that this government, instead of defending us from cutthroats, has transformed Italy into a useful platform for terrorists”, Santanche said.
Italian Prime Minister Matteo Renzi thanked the police on Twitter for capturing the suspect, but was inundated by demands to explain the affair fully to parliament, while Interior Minister Angelino Alfano faced calls to resign.
Authorities in Tunisia have arrested nearly two dozen suspects in connection with the attack and fired senior police officials over alleged security failures.
On March 29th, Tunisian forces killed nine men allegedly belonging to the jihadist group accused of being behind the shooting, the Okba Ibn Nafaa Brigade.
Lokmane Abou Sakhr – an Algerian who allegedly masterminded the attack – was killed along with at least eight others from the notorious brigade.
The Bardo tragedy was met by global outrage, with leaders from Italy's Prime Minister Matteo Renzi to France's President Francois Hollande and Palestinian leader Mahmud Abbas travelling to Tunis to take part in a march to denounce terrorism.
Tunisia has seen an upsurge in Islamic extremism since the overthrow of longtime strongman Zine El Abidine Ben Ali in 2011.
Authorities say as many as 3,000 Tunisians have gone to Iraq, Syria and Libya to join jihadist ranks, raising fears of returning militants plotting attacks.