China reported better-than-expected trade figures for the month of June as a recovery in global demand spurred exports.

In June, exports from the world's second largest economy posted a 11.3 percent increase from a year ago and a 17.2 percent rise in imports over the same period in dollar terms, Reuters reported citing China's General Administration of Customs.

That left China with the a trade balance of $42.77 billion for the month, higher than a Reuters poll forecast of $42.44 billion.

Analysts polled by Reuters had expected exports to rise 8.7 percent while imports were predicted to rise 13.1 percent.

Data from China is closely watched by investors amid concerns about a slowdown in growth and a rise in debt levels in the country.

The positive trade data in June came after China reported stronger-than-anticipated exports and imports a month ago.

Imports have been strong in recent months, driven largely by iron ore and other commodities used to feed a year-long construction boom, while exports have rebounded thanks to stronger global demand after several years of contraction.

"Looking ahead, we expect export growth to slow on uncertainties in external demand due to rising geopolitical risks and the stronger CNY/USD exchange rate in the first half of 2017," Nomura analysts wrote in a note after the data release.

"Import growth is also likely to moderate along with export growth, in our view. The cooling property market (in terms of sales) is likely to lead to slower domestic investment growth, which may also weigh on import growth," the bank's analysts added.

China had a $25.4 billion trade surplus with the United States in June, up from $22.0 billion in May, customs data showed on Thursday.

According to a Reuters calculation, the surplus with the U.S. was China's highest since October 2015, when it was $25.5 billion.

—Reuters contributed to this report.