The president and First Lady Melania Trump will be guests of the Queen and attend a ceremony in Portsmouth to mark 75 years since the D-Day landings.
He will also have official talks with the prime minister at Downing Street.
Mr Trump previously met the Queen at Windsor Castle when he came to the UK in July 2018 on a working visit.
The White House said the upcoming trip would reaffirm the “steadfast and special relationship between the United States and the United Kingdom”.
The president was promised a state visit by Prime Minister Theresa May after he was elected in 2016 – but no date was set.
Mrs May said June’s state visit was an “opportunity to strengthen our already close relationship in areas such as trade, investment, security and defence, and to discuss how we can build on these ties in the years ahead”.
But shadow foreign secretary Emily Thornberry voiced concerns about the visit, saying: “It beggars belief that on the very same day Donald Trump is threatening to veto a United Nations resolution against the use of rape as a weapon of war, Theresa May is pressing ahead with her plans to honour him with a state visit to the UK.”
Representatives of other countries invited to the Portsmouth event on 5 June include those from Canada, France, Germany, Australia, New Zealand, Belgium, Luxembourg, Poland, Norway, Denmark, Netherlands, Greece, Slovakia and the Czech Republic.
Portsmouth was one of the key embarkation points for many of the landing craft on D-Day, when, during World War Two, Allied forces invaded Nazi-occupied France marking the beginning of the end for Adolf Hitler’s domination of Europe.
The June gathering on Southsea Common will involve live performances, military displays and tributes to the Allied troops who fought in Normandy, including at least 11 Royal Navy vessels in the Solent and a flypast of 26 RAF aircraft.
After leaving the UK, Mr Trump and his wife will travel to France for a series of D-Day anniversary events on 6 June itself.
The president’s last visit to the UK – when he had talks with Mrs May at Chequers before heading to Scotland, where he owns the Turnberry golf course – was marked by demonstrations.
The National Police Chiefs’ Council estimated that the police operation for the president’s 2018 visit cost nearly £18m.
It said 10,000 officers from across the country were needed to cover the occasion.
The campaigners behind the 2018 protests – the Stop Trump Coalition and Stand Up To Trump – have vowed to mobilise “huge numbers” once again in response to the visit.
Shaista Aziz from the Stop Trump Coalition criticised the US president’s “politics of hate and bigotry”, while Sabby Dhalu from Stand Up To Trump called for people to “take to the streets and say clearly that Donald Trump is not welcome here”.
But Sarah Elliott, chair of Republicans Abroad, denied that President Trump courted the support of racists, telling the BBC he won in many areas that had elected Barack Obama twice. “He spoke to the people and what they wanted to hear,” she said.
A spokeswoman for Commons Speaker John Bercow said a request for Mr Trump to address Parliament – an event often associated with a state visit – would be “considered in the usual way”, but did not say whether a request had yet been received.
Mr Bercow – who, as Speaker, has the power to veto who addresses Parliament – previously said he would be “strongly opposed” to Mr Trump addressing the Houses of Parliament during a state visit.
The President of The United States of America, President Donald J. Trump, accompanied by Mrs Melania Trump, has accepted an invitation from Her Majesty The Queen to pay a State Visit to the UK. pic.twitter.com/e3ANW9bUKa
BBC royal correspondent Jonny Dymond said Mr Trump avoided London on his last visit and made it clear he did not particularly want to come to the capital if he was going to face protests.
However, our correspondent said a key part of a state visit is the procession down the Mall in front of Buckingham Palace and it is thought protesters will gather there – not a first for a state visit.
Once inside Buckingham Palace, it is expected the Queen will host a banquet for around 150 guests in Mr Trump’s honour.
The Queen has hosted two previous state visits from US presidents – George W Bush in November 2003, and Barack Obama in May 2011.
What is a state visit?
A state visit is a formal visit by a head of state and is normally at the invitation of the Queen, who acts on advice from the government.
State visits are grand occasions, but they are not just ceremonial affairs. They have political purpose and are used by the government of the day to further what it sees as Britain’s national interests.
Once the location and dates are confirmed, the government, the visiting government and the royal household will agree on a detailed schedule.
The Queen acts as the official host for the duration of the trip, and visitors usually stay at either Buckingham Palace or Windsor Castle.
There is usually a state banquet, and a visit to – and speeches at – the Houses of Parliament may be included. The Speaker of the House of Commons is one of three “key holders” to Westminster Hall, and as such, effectively holds a veto over who addresses Parliament.
The Queen usually receives one or two heads of state a year. She has hosted 109 state visits since becoming monarch in 1952.
The last state visit to the UK was in October, when King Willem-Alexander and Queen Maxima of the Netherlands came for two days.
The official website of the Queen and the Royal Family has a full list of all state visits since then, including details of how the ceremonies unfold.