The tournament was played at the new Atos Markham Pan Am/Parapan Am Centre built for this summer's Games in Toronto.
Canada and Brazil earned a berth for this summer's FINA world championships in Russia with top-two finishes.
The Canadians trailed 6-5 going into the fourth quarter but Ottawa's John Conway tied the match with his second of the game and McElroy fired the last two goals with 4:15 and 3:29 remaining. Regina's Kevin Graham scored twice for Canada.
Canada assured itself a top-two finish by hammering Argentina 17-3 in Saturday's semifinal. Montreal's Nicholas Constantin-Bicari, Calgary's Scott Robinson and Conway led the winners with three goals apiece.
Earlier, Sisters Carmen Eggens and Monika Eggens of Pitt Meadows, B.C., scored three goals apiece as Canada defeated Brazil 9-6 Sunday morning to take two of the three matches this weekend from their Pan Am rivals.
Emma Wright of Lindsay, Ont., added two and Christine Robinson of Lachine, Que., scored one for the victors. Canada fell behind 2-0 early in the match then scored five unanswered goals to finish the first half.
On Saturday, Krystina Alogbo of Riviere-des-Prairies, Que., scored three times as Canada beat the Brazilians 10-4. In their opening encounter on Thursday, Brazil edged Canada 10-9.Suggest a correction