Scottish farmers are set to benefit from more than £640m of rural funding over the next year.

Rural secretary Fergus Ewing said much of the money will go to farm businesses and crofters.

However, he warned that support for the sector is being put at risk by the prospect of a hard Brexit.

Scotland is expected to have received €4.6bn (£3.9bn) from the European Union between 2014 and 2020.

The Scottish Government said rural communities face losing EU subsidies, including those paid under the Common Agricultural Policy (CAP) and the rural development programme.

Mr Ewing said: "Agreement on the Scottish budget means I can confirm that rural Scotland will receive over £640m of support in the coming year.

"Much of that goes directly to farm businesses and crofters, but significant sums will also continue to be invested in grants for environmental measures, tree planting, food processing and maritime development.

"It helps to support jobs, businesses, infrastructure and livelihoods.

"Brexit puts this all at risk. While the UK Government has offered some assurances on funding over the short-term, which we have committed to pass on in full, there are still more questions than answers in the longer-term.

"For example, there are still no guarantees for the Less Favoured Area Support Scheme from 2019.

"The continued uncertainty could have a devastating impact on our farming and food sectors. Any moves to 'Barnetise' CAP payments could see Scotland lose up to half of the current CAP allocation, which has been tailored to meet our specific needs.

"Agriculture is fully devolved and the Scottish Government must retain powers to manage rural policy and determine funding levels.

"I am very clear that there may be issues where it will make sense to have a UK-wide framework.

"However, any such framework must be on the basis that the powers sit with the devolved administrations and any such frameworks must be entered into willingly and not imposed by the UK Government."

A UK Government spokesman said: "Scotland's farmers make a vital contribution to the country, producing food, providing jobs, and generating more than £1bn for the economy.

"We are determined to get the best deal possible, not least for our hard-working farmers.

"The Scottish Government and the views of Scottish farmers will play an important part in helping shape our discussions around our exit from the EU and we will continue to work with all the devolved administrations to achieve an outcome that works for all parts of the UK."