Johnson made the remarks on a 24-hour visit to Kabul, his first, after a trip to neighbouring Pakistan.
"The message I have for President (Ashraf) Ghani and Chief Executive (Abdullah) Abdullah is that we are here for the long term and we are committed to Afghanistan's side," Johnson told reporters, adding that many Britons had lost their lives in the country.
He was referring to the campaigns of the 19th century that left thousands of British empire soldiers dead, as well as the troops that fought the Taliban until 2014 after the American invasion in 2001.
"Wherever I go people aren't interested in whether the UK is part of the European Union or not," said Johnson. "What they want to know is are we going to help them and none of the key areas will be affected by our relationships with other European countries."
More From This Section
Johnson campaigned vigorously in the June referendum for Britain to leave the European Union.
"The British sacrifice in this country has been around for a long time and will be around for the long term," said Johnson. "We intend to remain involved and even more so than before".