Libya responded to the arrests by suspending oil deliveries to Switzerland, withdrawing assets worth an estimated $7bn from Swiss banks, ending bilateral co-operation programmes and placing restrictions on Swiss companies.
Two Swiss businessmen in Libya were also banned from leaving the country.
Merz said at Thursday's news conference that "the Libyans have assured me that they [the two businessmen] will be allowed to leave before September 1".
"Today I have fulfilled my mission and achieved my goals of wiping the slate clean of last year's incident and opening the Libyan market" to Swiss firms once again, the president said.
After more than a year of strained relations between the two countries, Merz said "it is a satisfying outcome for me".
Mahmudi said Libya and Switzerland would set up a joint committee to examine what he called the "tragic incident" in Geneva.
The prime minister said: "Today we have been able to take a first step towards solving this problem.
"Switzerland has presented its official and solemn apologies concerning the unjust arrest of the son [of Gaddafi]."
Last month, Micheline Calmy-Rey, the Swiss foreign minister, said her country was trying to organise a meeting between Merz and the Libyan leader to defuse the crisis.
For Switzerland, the dispute is "a matter of law, while for Libya it is a matter of honour," she said.
The authorities in Libya had sought an apology over the incident and had also unsuccessfully asked for the people responsible for the arrest of the Gaddafis to be punished.
Merz also had talks in Tripoli with Mussa Kussa, Libya's foreign minister.