Iceland's ruling coalition has named Sigurdur Ingi Johannsson as the new PM, with early elections to be held in the autumn.
Mr Johannsson, 53, is agriculture and fisheries minister and deputy leader of the Progressive Party (PP).
The move comes after PM and PP chairman Sigmundur Gunnlaugsson stepped down in the wake of the leaked Panama Papers.
The leaks, from Panama law firm Mossack Fonseca, showed Mr Gunnlaugsson owned an offshore firm with his wife.
It was not declared when he became an MP. Mr Gunnlaugsson says he sold his shares to his wife and denies any wrongdoing. But he is accused of concealing millions of dollars' worth of family assets.
With protesters keeping up a steady drumbeat of pots and pans outside parliament, for the third day in a row, members of Iceland's political parties held lengthy discussions inside.
The demonstrators sensed a deal was in the offing, and hurled eggs and fruit at the building as a mark of disgust. For many of them, nothing less than the resignation of the entire government would do.
But eventually came word that the two coalition parties, the Progressives and Independents, had reached agreement.
Opposition parties don't like the deal and some are vowing to go ahead with a vote of no confidence. The government has a comfortable majority and it seems the crisis may be over, for now.
But polls suggest the Progressive Party has lost much of its support and that the tiny Pirate Party, founded just over three years ago, stands to make significant gains. Unless this government's fortunes change, it could be out of power in a few months' time.
Mr Gunnlaugsson is one of dozens of high-profile global figures mentioned in the 11.5 million leaked financial and legal records, which were first published on Sunday.
Pressure on Mr Gunnlaugsson to step down had been building since then, with thousands of people protesting outside the parliament building in the capital Reykjavik on Monday and opposition parties tabling a confidence motion.
Earlier on Tuesday, Mr Gunnlaugsson had asked President Olafur Ragnar Grimsson to dissolve parliament and call an early election, although the president said he would need to talk to parties.
Iceland's prime minister stepped down ahead of a confidence vote in parliament
But later on Wednesday, Mr Johansson said: "We expect to have elections this autumn," adding that in the meantime the government had work to do.
"We will continue to lead a good government and keep up the good work we have worked on for the last three years and get finished with all those good works we have started on," he said.
Pirate Party leader Birgitta Jonsdottir also told reporters in parliament that early elections would be held in the autumn.
Mr Gunnlaugsson has put out a statement insisting he has not in fact resigned and that Mr Johannsson will take over the post "for an unspecified amount of time".
The documents leaked from Mossack Fonseca show that Mr Gunnlaugsson and his wife bought the company Wintris in 2007.
He did not declare an interest in the company when entering parliament in 2009. He sold his 50% of Wintris to his wife, Anna Sigurlaug Palsdottir, for $1 (£0.70) eight months later.
Mr Gunnlaugsson maintains no rules were broken and his wife did not benefit financially.
In his statement, Mr Gunnlaugsson said he had no wish to stand in the way of further government work, such as reform of the financial system.