Mr Trump and his wife Melania will be guests of the Queen during the three-day visit, which begins on June 3.
The long-awaited state visit comes more than two years after Prime Minister Theresa May offered the invitation to the US leader just days into his presidency, when they met for the first time at the White House in January 2017.
Mrs May was widely criticised for bestowing such an honour on a controversial figure and campaigners have already pledged to organise demonstrations.
Buckingham Palace said in a brief statement: "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 United Kingdom from Monday 3rd June to Wednesday 5th June 2019."
Prime Minister Theresa May said: "The UK and United States have a deep and enduring partnership that is rooted in our common history and shared interests.
"We do more together than any two nations in the world and we are both safer and more prosperous because of our cooperation.
"The State Visit is 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."
Mr Trump will also hold a bilateral meeting with Mrs May during the visit, and attend a ceremony in Portsmouth to commemorate the 75th Anniversary of D-Day.
A White House spokesman said: "This state visit will reaffirm the steadfast and special relationship between the United States and the United Kingdom.
"In addition to meeting the Queen, the President will participate in a bilateral meeting with Prime Minister Theresa May.
"While in the United Kingdom, the President and First Lady will attend a ceremony in Portsmouth to commemorate the 75th Anniversary of D-Day, at one of the primary embarkation sites for the Allied operation that led to the liberation of Europe during World War II."
Mr Trump and his wife will then travel to Normandy on June 6.
President Trump will be a guest of Her Majesty The Queen during the visit from June 3-5, and will also have discussions with the Prime Minister in Downing Street.
On June 5, he and other representatives of the Second World War Allies - as well as Germany - are expected to attend a major international event in Portsmouth to mark the 75th anniversary of D-Day.
The gathering on Southsea Common will involve live performances, military displays and tributes to the Allied troops who fought in Normandy, including a flypast of 26 RAF aircraft and at least 11 Royal Navy vessels in the Solent.
On June 6, the Prime Minister will travel to Normandy to attend a number of commemorative events including the inauguration of the British Normandy memorial in Ver-Sur-Mer.
Mrs May said: "D-Day was an unparalleled international military operation and a turning point in the Second World War. The freedom we have today would not be possible without the incredible sacrifice of troops from across the world 75 years ago.
"I am proud that the UK will host representatives and veterans from Allied nations to pay tribute to that sacrifice and recognise the extraordinary co-operation that made the Normandy landings possible.
"And today - as we face new and different challenges to our security - we must continue to stand together to uphold our shared values and way of life."
Other countries invited to send representatives to the Portsmouth event include Canada, France, Australia, New Zealand, Belgium, Luxembourg, Poland, Norway, Denmark, Netherlands, Greece, Slovakia and the Czech Republic.