The government's new security bill cleared parliament's Lower House on Wednesday and now heads to the Senate for final approval.
In order to ensure its approval, the package was divided into three 'maxi-amendments' and the government asked for a confidence vote on each one.
The first vote saw the government win by a margin of 316 to 258 votes, in the second it collected 315 votes to 246 and in the third, for which Premier Silvio Berlusconi was present, the vote was 315 to 237.
Divisions within the majority backing Berlusconi's center-right government resulted in the bill's original version being modified in ways which some government parties, in particular Interior Minister Roberto Maroni's Northern League, considered unacceptable.
The government, in fact, was defeated in secret ballot voting on amendments regarding the extension of the period of time illegal immigrants can be be kept in temporary detention centers.
The final version of the bill restores the six-month period from the two-month one voted on the floor.
Other measures important for the Northern League and reinstated in the bill were redefining illegal immigration as a criminal offense and authorising citizen patrols, which critics have likened to vigilante groups.
A number of compromises were reached within the majority in order to ensure unity, including dropping the obligation for school officials to report immigrants without legal status who sought to enroll their children in public schools.
A similar measure encouraging doctors to report any illegal aliens they treated was struck from the bill in its first reading in parliament but may be presented as a separate bill in the future.
Aside from the center-left opposition, the security bill has also drawn criticism from the Catholic Church and organizations like Save the Children, both of which are concerned over provisions regarding children and the classification of illegal immigration as a crime.