SHANGHAI -- Canada's men's basketball team ended the FIBA World Cup with a 82-76 loss to Germany on Monday, but will still finish high enough to get a second chance at qualifying for the 2020 Tokyo Olympics.

Kyle Wiltjer had 18 points, while Khem Birch added 15 to top the Canadians, who went 2-3 in their first World Cup appearance since 2010. Cory Joseph added nine points.

Dennis Schroder had 21 points to top Germany, while Max Kleber finished with 20.

Canada will learn its final World Cup placing later Monday when FIBA announces the 17th- to 32nd-place finishers.

The Canadian men's program seemed poised for a breakout summer. Finally, Canada's NBA players were expected to suit up for the national team. But one NBA star after another opted out of national team duty, leaving Birch and Joseph as Canada's only NBA players in China.

While there'd once been hope of even climbing the medal podium at the World Cup, that dream died quickly in China. Canada was relegated to the classification round just two games into the tournament, with losses to Australia and Lithuania.

Germany -- led by NBA players Schroder (Oklahoma City), Kleber (Dallas), and Daniel Theis (Boston) -- dropped close games to France and the Dominican Republic in the first round.

The game capped a six-week odyssey that took the Canadian team to Winnipeg, Australia and China. Now, coach Nick Nurse and Canada Basketball will turn their attention to next June and their second-chance Olympic qualifying tournament. Just four spots for the 2020 Tokyo Games will be up for grabs -- so, Canada must win its six-team tournament, and on the heels of its disappointment, will likely have a low seed and end up in a tough group.

The big question for Canada: who'll turn out to play?

Germany took an early seven-point lead in an almost full Shanghai Oriental Sports Center arena. Andrew Nembhard, with a behind-the-back dribble, layed it in to cut Germany's lead to 17-12 leading into the second.

The Canadians opened the second with a 20-10 run, and when Kaza Kajami-Keane drew a foul for a couple of free throws midway through the period, Canada was up by six. Schroder drove to the hoop for a layup that sent Germany into the halftime break up 36-33.

Both teams battled hard in the second half and the game went into the fourth quarter knotted at 56-56.

Germany opened the fourth on a 7-0 run. But Birch then sprinted to a long, leading pass and finished with a dunk that cut Germany's lead to two with six minutes to play. Wiltjer connected on a three to tie the game a minute later, but that was as close as the Canadians would come. Joseph connected on a three with a minute-and-a-half to play, but Germany responded to every one of Canada's baskets.

Nurse has griped about the referees all tournament long. He couldn't understand why, out of the 84 countries to draw from, Canada had the same referee -- Bulgaria's Martin Horozov -- for four of its last five games. Horozov was quick to call a technical on Nurse when the coach argued a call late in the first quarter.

Officials ejected Germany's Paul Zipser in the third quarter after he picked up two technicals.