The U.S. budget surplus was $71 billion at the end of June, down 39 percent from the same period last year, according to data released by the Treasury Department on Friday.

Analysts polled by Reuters had expected a surplus of $80 billion last month. The surplus was $117 billion in June of 2013.

The year-to-date deficit at the end of June was $366 billion, the lowest since the same period in fiscal 2008, compared with a deficit of $510 billion in the same period in fiscal 2013.

Last month's budget results were affected by differences in the calendar. If adjusted for timing-related transactions, the budget surplus in June would have been $25 billion.

Receipts for the month totaled $324 billion, up 13 percent from a year ago, the monthly budget statement said, bringing the year-to-date total receipts to $2.26 trillion.

Outlays last month were at $253 billion, up 49 percent from last year, for a year-to-date total of $2.62 trillion. (Reporting by Elvina Nawaguna; Editing by Paul Simao)