Prime Minister Theresa May has promised to work for a "practical solution" to the future of the border between Northern Ireland and the Republic following Britain's exit from the European Union.

Mrs May was speaking after talks with First Minister Arlene Foster and Deputy First Minister Martin McGuinness on her first visit to Northern Ireland as PM.

READ MORE: Brexit return to 'hard border' of watchtowers, customs and checkpoints on Irish border must not be allowed, leaders say

She said she would seek to reach a Brexit deal with Brussels which was "in the best interests of the whole of the United Kingdom".

"If you look ahead, what is going to happen when the UK leaves the European Union is that of course Northern Ireland will have a border with the Republic of Ireland, which will remain a member of the European Union," said Mrs May.

"But we've had a common travel area between the UK and the Republic of Ireland many years before either country was a member of the European Union.

"Nobody wants to return to the borders of the past. What we do want to do is to find a way through this that is going to work and deliver a practical solution for everybody - as part of the work that we are doing to ensure that we make a success of the United Kingdom leaving the European Union - and that we come out of this with a deal which is in the best interests of the whole of the United Kingdom."

Mrs May said her talks at Stormont Castle with Mrs Foster and Mr McGuinness had concentrated on the impact of the Brexit vote, and characterised the discussions as "very constructive ... positive".

She repeated her vow, made on the steps of Downing Street moments after becoming PM on July 13, that she would govern "for the whole of the United Kingdom - of which Northern Ireland is a valued part".

She added: "I'm very clear that the Government will deliver on the Stormont House Agreement and the Fresh Start Agreement."

Mrs May said: "Brexit means Brexit, but we will be making a success of it and I am clear that the Northern Ireland Executive and the other devolved governments will be involved in our discussions as we set forward the UK position.

READ MORE: Brexit return to 'hard border' of watchtowers, customs and checkpoints on Irish border must not be allowed, leaders say

"I recognise there's a particular circumstance in Northern Ireland because, of course, it has a land border with a country, the Republic of Ireland, that will be remaining in the EU.

"We've had constructive talks about the will that we all have to find a way through this which is in the best interests of Northern Ireland and the best interest of the United Kingdom as a whole."

In Northern Ireland 56% voted to Remain and the UK-wide vote to Leave has triggered intense political wrangling in the region. The result has sparked a renewed debate on a potential referendum on Irish reunification with the Republic of Ireland, an EU member state.

The Stormont Executive is divided on the EU issue, with Mrs Foster's Democratic Unionists backing Brexit and Mr McGuinness's Sinn Fein advocating Remain.

Ahead of her visit, Mrs May insisted the UK's departure from the European Union must work for Northern Ireland and said she would work with all the province's political parties as she prepares for withdrawal negotiations.

People and goods going between Northern Ireland and the Republic are currently able to move freely due to the common travel area (CTA), which was established in the 1920s.

However, questions and concerns have been raised about what this means for the CTA and for both economies in the wake of the Leave vote.

French President Francois Hollande has said the Irish border will be a special case in the Brexit negotiations.

Mrs May added: "I am delighted to be visiting Northern Ireland. I made clear when I became Prime Minister that I place particular value on the precious bonds between the nations of the United Kingdom.

READ MORE: Brexit return to 'hard border' of watchtowers, customs and checkpoints on Irish border must not be allowed, leaders say

"I want to assure the people of Northern Ireland that I will lead a Government which works for everyone across all parts of the United Kingdom, and that Northern Ireland is a special and valued part of that union."