First Minister Nicola Sturgeon and Chancellor George Osborne have brought months of negotiation to an end by agreeing a deal on Scotland's future finances.

But what exactly is a fiscal framework and what does it mean for the Scottish Parliament? Here are the key facts:

Q. What is the fiscal framework?

A. The complex financial arrangements that underpin the Scotland Bill. The historic legislation will devolve almost full control over income tax, other levies and a £2.5billion welfare budget to Holyrood.

That means the Scottish Government's annual budget allocation from the Treasury, known as the block grant, must be adjusted, it needs extra borrowing powers and cash to set up new administrative systems.

Q. Why was agreement so difficult to reach?

A. Both the Scottish and the UK governments based their approach on the Smith Agreement, the cross-party deal that recommended the new powers contained in the Scotland Bill. But as economists observed, some of the key principles set out in Smith were difficult to reconcile and open to interpretation.

Q. So what, exactly, were the stumbling blocks?

In the end, the big question of how to reduce the block grant proved the most difficult. The Treasury's initial plan would have reduced Holyrood's budget by £1.3billion per year after 15 years or £7billion in total after the first decade because of Scotland's slower population growth. The Scottish Government said according to the Smith Agreement's 'no detriment' rule it should not lose a penny. The Treasury, quoting Smith's 'taxpayer fairness' rule, said protecting Scotland's budget from demographic effects was unfair on English taxpayers, who would see increasing amounts of their income tax spent in Scotland.

Q. How was this resolved?

A. It wasn't so much resolved as fudged.

The two governments have agreed to use the Treasury's preferred adjustment mechanism, but tweaked to ensure it provides the same level of funding as the Scottish Government's favoured system. The arrangement will be reviewed in 2022. 

Q. Who got the best deal?

A. Finance Secretary John Swinney has negotiated hard and struck a good deal, winning his main demand of protecting the Scottish Government's budget and guaranteeing Holyrood will not lose out compared with the present set-up.

However, both sides deserve credit for compromising and ensuring the Scotland Bill powers are delivered as promised.

But the fundamental disagreement remains - and it will inevitably resurface when the deal is reviewed after the five year transition period. Expect a similar row after the  UK and Scottish elections in 2020 and 2021 respectively.

Q. What happens next?

A. The deal itself will be published later this week. Though Westminster legislation, the Scotland Bill must also be approved by MSPs. Holyrood's devolution committee will produce a report on the Bill and the fiscal framework in time for a final vote before Holyrood breaks up on March 23 for the election campaign. Given the deal has been backed by the Scottish Government and welcomed by opposition parties that is little more than a formality.