The record surplus was an increase of $2.7 billion on the April figure and well above market expectations of about $10.5 billion.
Exports rose $5 billion (9.5 per cent) to $58.4 billion, driven by rises in shipments of coal, coke and briquettes and other mineral fuels, the Australian Bureau of Statistics reported on Thursday.
Imports rose $2.3 billion (5.8 per cent) to $42.4 billion, led by imported fuels and lubricants, and non-industrial transport equipment.
In other data, payroll jobs rose 0.1 per cent in the month to June 11, reflecting the ongoing impact of COVID-related disruptions.
The ABS said the latest monthly increase compared with a 0.4 per cent fall a year earlier during Victoria's fourth lockdown.
"Payroll jobs continued to grow more slowly in 2022 than in 2021, apart from a short-term rise in jobs around the federal election in the public administration and safety industry in May," the bureau's head of labour statistics Bjorn Jarvis said.
"The slower growth in payroll jobs over the month to mid-June continues to reflect the ongoing impacts of COVID-related disruption and short-term employee absences, particularly for people without paid leave entitlements."
The largest growth in payroll jobs came in the Northern Territory (up 0.6 per cent) and Queensland (up 0.4 per cent), which were largely seasonal.
The biggest rises were in the arts and recreation services (up 1.4 per cent) and public administration and safety industries (up 1.1 per cent).
Overall, payroll jobs were 6.8 per cent higher at June 11 than at the start of the pandemic, and were up on pre-pandemic levels in 14 of 19 industries.
Meanwhile, new job advertisements declined for the first time since December, but remained well above pre-pandemic levels.
The monthly SEEK new job ads indicator fell 2.1 per cent in June following five consecutive monthly gains.
NAB economist Tapas Strickland said it was too early to conclude if this was the start of a turning point away from strong demand for workers.
Overall, job ads are 71.9 per cent above pre-pandemic levels and have stabilised in the hospitality and tourism sector.
The largest decline was in the NT (down five per cent), followed by South Australia, WA and Tasmania (down four per cent).
The largest falls outside the self-employed category were in science and technology (down 11 per cent) and advertising and media (down 10 per cent).
"The reopened international border may be starting to see more acute pressures ease in industries including agriculture and hospitality and tourism, where a large share of the workforce was drawn from temporary visa holders prior to the pandemic," Mr Strickland said.
"Despite the monthly fall, job ads remain well above pre-pandemic levels and continue to indicate strong labour demand and a tight labour market."
It remains likely there will be a further fall in the unemployment rate when new labour force data is released next week.