The measure provides $3.8bn to the UK and $1.9bn to the Netherlands from 2016 to repay expenditures to compensate citizens who lost money in the collapse of Icesave.
Grimsson's approval is required before the legislation becomes law, otherwise the legislation will be put to a national referendum.
The payout has stirred up considerable resentment among many ordinary Icelanders hard hit by their country's financial meltdown in 2008.
"Treason!" cried out one opposition politician after the announcement that the bill had passed, while a politician from the governing leftist coalition shouted "Congratulations, Iceland!".
Icesave was an online subsidiary of the Landsbanki bank that had to be rescued in October 2008 as the global credit crunch hit.
It had attracted thousands of savers due to its high interest rates.
The British and Dutch governments turned to Reykjavik for the money to be returned, and an initial compensation deal was approved by Iceland's parliament in August.
But amendments negotiated by Johanna Sigurdardottir, the country's Social Democratic prime minister, in order to get the deal through parliament, were rejected by Britain and the Netherlands.
The dispute threatened to sink Iceland's efforts to quickly join the European Union, forcing Sigurdardottir to return to parliament with a new bill in line with the initial deal.
The measure adopted late on Wednesday foresees staggering through to 2024 the payment of the $5.7bn, which is equivalent to nearly 40 per cent of the country's annual gross domestic product.
A poll taken in August suggested nearly 70 per cent of Icelanders were against the Icesave deal, the compensation amounting to about $17,000 for each citizen on the island nation of 320,000 people.
"History will show that we are doing the right thing," Steingrimur Sigfusson, the country's finance minister, said after the vote.
But Birkir Jon Jonsson, deputy leader of the opposition Progressive Party, said: "How this government has handled this issue has been shameful from the beginning."
A petition asking Grimsson to veto the measure has already garnered nearly 40,000 signatures, a record in Iceland.
Grimsson indicated he would meet members of InDefence, which opposes compensation, before making a decision.
The dispute over the compensation scheme had also delayed the disbursement of funds under of a $2.1bn IMF standby loan arranged in November 2008 following the collapse of Icelandic banks.
The IMF announced on December 14 it had reached an agreement with Iceland on the release of a third tranche of the loan.