Negotiations over the fiscal framework have been going on since March 2015, with a lengthy deadlock over the issue of Scotland's block grant.
Confirming a deal had been done, First Minister Nicola Sturgeon said "not a single penny" would be taken from the Scottish government's budget.
Details of the deal will be published soon so Holyrood scrutiny can begin.
The deal, which is the financial basis for new powers to be devolved as part of the Scotland Bill, was settled after Chancellor George Osborne spoke to Ms Sturgeon on the phone.
He said the agreement created a "stronger Scotland in a stronger UK".
The MP told the BBC: "It delivers on the vow we made to the people of Scotland.
"It is fair to the taxpayers of all of the UK and it gives Scotland one of the most powerful devolved parliaments in the world."
Ms Sturgeon and Finance Secretary John Swinney had earlier informed MSPs that there was only one issue outstanding in the talks, the substance of a five-year review of the agreement.
The two sides had disputed a key line of the Smith Commission agreement on new powers, which said there should be "no detriment" to either the UK or Scottish budgets as a result of the deal.
Ms Sturgeon said the deal agreed would see "not a single penny of detriment" now or "at any point in the future".
Addressing parliament, she added: "There is now an agreement in principle that we can recommend to parliament.
"There will be not a single penny of detriment to the Scottish government's budget as a result of the devolution of powers during the transition period, for the next six years to March 2022."
She paid tribute to Mr Swinney over his role in the protracted negotiations, saying it had been much "harder work than it should have been" to stop the Treasury from carrying out a "cash grab" from Scottish budgets.
Prime Minister David Cameron said it was "a significant day of devolution", which would deliver a "powerhouse parliament" in Scotland.
He added: "We have reached a deal which is fair to Scotland and fair to the whole of the UK.
"It delivers accountability to the Scottish government and transforms politics in Scotland. It means May's Holyrood elections can be fought on the issues which matter most: how the Scottish government should use these extensive new powers, rather than what they are.
"I welcome this agreement which shows that Scotland's two governments can work constructively together for the benefit of Scottish people."
Scottish Labour leader Kezia Dugdale welcomed the deal, saying it was "a historic moment for Scotland". Her party had backed the Scottish government's position in the negotiations.
She said: "Scottish politics will never be the same again thanks to these new powers. We have entered a new and exciting era of devolution."
Secretary of State for Scotland, David Mundell, who later gave evidence to the devolution committee on the matter, said he was "very pleased" that a deal had been reached.
He insisted he had "always been confident" an agreement would be reached because both the UK and Scottish governments had wanted what was best for Scotland and the whole of the UK.
The final sticking point in the talks revolved around how Scotland's block grant from Westminster would be reduced in light of new fundraising powers being devolved as part of the Scotland Bill.
Scotland's population is projected to grow more slowly than that of the UK's in the coming years, and the two parties disagreed over how to balance out the financial impact of this after the first five years of the deal.
A compromise was reached on how this would work for the first five years. However, if no deal could be reached at the review, the UK government wanted to revert to the original proposal, which Ms Sturgeon described as Scotland bearing the brunt of "population driven detriment".
The new deal will see the review carried out without any prior expectation of Scotland taking on an extra financial burden, and an independent study would be carried out to inform that process.
The Scottish and UK governments have reached a financial deal enabling new powers for Holyrood.