Braga 1-0 Birmingham
Hugo Viana's strike gave Braga a win which leaves Birmingham's Europa League fate out of their own hands.
Blues started well and had the chance to lead but Nikola Zigic's penalty was saved after Ewerton fouled Wade Elliot.
Braga defender Ewerton should have been sent off for a second booking but stayed on and Viana then saw his long-range shot go in off Curtis Davies.
Birmingham now need to beat Maribor in their last group game in December to have any chance of progressing.
Braga are through and will be joined in the last 32 by Club Brugge if the two sides play out a draw in their final fixture in Belgium.
But should Braga win and Birmingham triumph over Maribor, Chris Hughton's side will qualify as a result of their superior head-to-head record over Brugge.
The Belgian side looked set for an exit as they trailed Maribor 3-0 but pulled off a remarkable comeback to score four times in the final 16 minutes to win 4-3.
Birmingham face Championship trips to play-off rivals Cardiff and Hull next week but Hughton named a strong side in Portugal and was rewarded with a superb opening quarter against last season's Europa League finalists.
Blues attacked from the off and could have had a penalty in the first minute when Chris Burke's cross struck the hand of Elderson inside the area.
Referee Markus Strombergsson waved play on but did award a spot-kick 10 minutes later when Ewerton was caught in possession by Elliott and then clumsily hauled him down.
The defender was booked but Zigic wasted the chance when his tame effort was easily stopped by Quim's sprawling save.
Ewerton then should have been sent off minutes later when he slid in rashly to bring down Burke on the edge of the area but he was somehow spared a second yellow card.
Steven Caldwell then saw a header saved by Quim as Birmingham piled on the pressure but eventually the hosts wrestled back control of the game and, with captain Alan influential after moving from the right flank to the left, began to look dangerous.
Midfielder Mossoro looped a 25-yard effort wide and then slalomed through two tackles to break into the area, only to be denied by a fine covering challenge from Keith Fahey.
Birmingham started the second period well but fell behind to a cruel deflected strike from former Newcastle man Viana.
The midfielder collected a ball from the right 30 yards from goal and saw his hopeful low shot strike Davies to deflect past a wrong-footed Boaz Myhill and into the bottom corner.
Zigic headed over a David Murphy cross as Birmingham rallied but the hosts should have sealed the win in the last few minutes.
Lima was sent free by a long ball and after Myhill made a strong save, substitute Paulo Cesar blazed the rebound over the top.
Hughton will now turn his attention towards moving into the the top six in the Championship but Blues could yet extend their European exploits beyond Christmas with victory over Maribor on 15 December.