Bosnia dominated the early going, building a 36-22 lead by half-time, and looked like being comfortable winners.
They extended their lead in the third quarter, but whatever Moncho Lopez said to his players at half-time had clearly had an effect as Portugal began to compete much more effectively.
In the final quarter, Portugal piled on the pressure as they reeled off a 20-9 run that brought them right back into contention, only to fall short at the end.
Nihad Dedovic made four-of-seven (57%) from the field and six-of-nine (67%) at the free-throw line to lead the victors with 15 points.
Ratko Varda added 14 points and Ivan Opacek had 11 points.
Portugal wasted 17 points from Joao Coelho and 12 from Joao Gomes.
Carlos Andrade was held to nine points as he went 0-for-6 from three-point range.