The number of visitors from North America shot up by 34%.
While in the UK, the visitors spent Â£2.2bn, a rise of 2%, the Office for National Statistics (ONS) said.
The increase comes as the weak pound makes the UK more affordable for visitors, but also follows terror attacks in London and Manchester.
Meanwhile, UK residents took a June record of 7.2 million trips abroad, up 4%.
However, with the fall in the value of sterling putting them at a disadvantage, the amount they spent leapt by 15% to Â£4.6bn.
The big increase in visitors from North America, from 483,000 in June of last year to 650,000 this year, was "clearly buoyed by the particularly sharp drop of the pound against the dollar since mid-2016", according to Howard Archer, chief economic adviser to the EY Item Club.
The number of visitors from Europe rose by 2% to 2.241 million.
The weaker value of the pound since the Brexit referendum vote means that the UK is now a much cheaper destination than it used to be.
Many mainland Europeans, Americans and Chinese people are taking advantage of that.
That's clear from the cacophony of different languages and accents outside Buckingham Palace, and on the streets around the Palace of Westminster.
"It's a little more economical than it was a few years ago," says one visiting American tourist.
Meanwhile, a German man said the euro-pound rate has "made me quite happy".
UK tourism sector booms as sterling falls
The best month so far this year was April, with 3.7 million visitors coming to the UK - up 19% from a year earlier.
Over the April-to-June quarter the number of visitors from overseas rose to 10.75 million, up 8% from the same period a year earlier.
But while holiday visits were up by 20% to 4.7 million over the same three months, business visits were down by 4% at 2.4 million.
VisitBritain director Patricia Yates said: "Tourism is one of Britain's most valuable export industries and this continued growth demonstrates the industry's increasing importance as a key driver of economic growth across our nations and regions."
The number of visitors to the UK rose to 3.5 million in June, up 7% from the same month last year, according to official figures.