(Adds historical context, sectoral breakdown)
OTTAWA, July 17 (Reuters) - Foreigners bought C$21.43 billion ($20.03 billion) of Canadian securities in May, the highest since May 2012, as they scooped up a chunk of the large increase in the net supply of federal and provincial bonds, Statistics Canada said on Thursday.
It followed purchases of C$10.20 billion in April and more than doubled the year-to-date tally to C$37.44 billion, compared with the C$31.24 billion registered in the same period in 2013.
Nonresidents invested C$15.92 billion in Canadian bonds, also the highest in two years. They bought C$6.89 billion in federal government bonds, following a divestment of C$15.40 billion in the previous five months.
So far this year, there has been a net outflow of C$1.96 billion from federal government bonds but an inflow of C$6.28 billion into overall government bonds, including lower levels of government.
Most of the rest of the bond purchases in May were in instruments issued by the provinces and federal government enterprises.
$1=$1.07 Canadian Reporting by Randall Palmer