Bern - Guillaume Hoarau scored in either half as Young Boys inflicted a 2-1 defeat on Juventus in their final Champions League group game on Wednesday in Switzerland, but the Italians still took top spot in Group H after Manchester United lost by the same scoreline to Valencia.
READ: Man United through as runners-up after limp defeat to Valencia
The Swiss champions proved too hot to handle for the Cristiano Ronaldo-led Italians whose 26-match unbeaten away run going back to November 2017 ended in freezing temperatures in Bern.
France forward Hoarau slotted in the first after half an hour from the spot at the Stade de Suisse, blasting in the second after 68 minutes to lift the spirits of his already-eliminated side who finished bottom of the group.
Paulo Dybala - who scored a hat-trick in Juve's 3-0 home win in Turin - came off the bench just after the second goal and pulled one back for Massimiliano Allegri's side ten minutes from time and had a second disallowed in injury time.
Juventus finish top of Group H on 12 points with United on ten, Valencia on eight and Young Boys with four.
"We achieved our objective by winning the group, even on a night where everything seemed to go wrong, maybe we weren't focused enough," said Allegri.
"We missed so many opportunities and gifted a penalty, so at the end of the day it was only right that we lost."
Ronaldo, the record scorer in the elite European competition with 120 goals, started the final group match despite Juventus already having secured a berth in the knock-out round as Allegri wanted to ensure his side avoided being drawn against Barcelona, Real Madrid, Manchester City or Paris Saint-Germain in the next round.
"Now the best part of the Champions League is coming," said Ronaldo, who has lifted the trophy five times.
"Today we're not happy because we wanted to win in the first half. I could have scored several goals and if I did, the result would probably have been different.
"I feel good physically. The fact of playing every match is a decision that I take together with my coach."
But veteran defender Giorgio Chiellini was rested ahead of next weekend's Turin derby in Serie A, as Allegri feared a potential injury on the artificial pitch in Switzerland.
Ronaldo had three chances to put Juventus on the scoreboard in the first half, but the visitors were impacted by Juan Cuadrado going off injured after twenty minutes with Alex Sandro coming off the bench.
Minutes later Brazilian Sandro conceded a penalty for bringing down Cameroonian midfielder Moumi Ngamaleu in the box.
Hoarau stepped up with Juventus goalkeeper Wojciech Szczesny at full stretch getting his fingers to the ball as it clipped the post and bounced back into the net.
The hosts came close to scoring a second just after the hour mark but Szczesny held Christian Fassnacht's header.
Hoarau again broke through after 68 minutes with Ngamaleu crossing to the French attacker who powered forward, cutting past Leonardo Bonucci to beat Szczesny.
Dybala came on after 72 minutes in place of Mattia De Sciglio with Ronaldo setting up the Argentine to pull a goal back eight minutes later.
Two minutes into injury time, Dybala thought he had bagged the equaliser with a volley but the goal was disallowed as Ronaldo was offside.
"I saw it, Ronaldo was in the path of the ball and the goal was offside," said Allegri.
"The important thing is that we won the group, even if its thanks to Valencia beating Manchester United," said Dybala.
"The defeat hurts, because we came here looking for the win, but it should serve as a lesson for the future."
It was the first away defeat for Juventus this season who have won seven times on the road in Serie A and twice in the Champions League.
The last away defeat dates back to November last year, a 3-2 loss to Sampdoria in the Italian league, since when Juventus have had 23 wins and three draws.
Their last Champions League away loss was in September 2017, 3-0 to Barcelona.
Allegri's side had dropped points only in two home games this term -- a 1-1 draw against Genoa in Serie A and a 2-1 defeat against United in Champions League.
Juve face city rivals Torino on Saturday, looking to extend their eight-point lead in Serie A.