Italy's foreign ministry thanked Libyan authorities, saying that help from a Libyan foundation was key to resolving the case.
The two men were abducted while travelling with a tour group in Niger's vast desert near the border with Chad.
Claudio Chiodi and Ivano De Capitani were held by a rebel group known as FARS, the foreign ministry said.
The two returned to Italy on Saturday evening aboard a flight from Tripoli.
Chiodi told reporters at Verona airport: "In the beginning, they [the kidnappers] passed themselves off as having a political idea.
"In reality, they were just bandits, without any kind of political aim. They were thieves, basically.
"There was a standoff with Libya with them, and in the end, they gave in."
The Italian ambassador in Tripoli told Sky TG24 TV that the men were freed on Thursday night.
The Italian foreign ministry did not give details about the Libyans' involvement, but Rome and Tripoli have strong economic ties and generally good relations.
The ministry statement said that the Italian military intelligence service and Italian diplomatic offices in the region also worked on the case.