Massimiliano Allegri felt everything seemed to go against Juventus as they lost 2-1 to Young Boys in their final Champions League group fixture.

Juve still went through to the last 16 as Group H winners despite their defeat on Wednesday, with Manchester United having lost 2-1 at Valencia.

Guillaume Hoarau's double – the opener coming from the penalty spot – put Young Boys in control before Paulo Dybala's thumping effort handed Juve a lifeline.

But, although Cristiano Ronaldo hit the post before playing a part in Dybala's stoppage-time wonder-strike getting disallowed, Allegri conceded a defeat – Juve's first away loss of the season – was a fair result.

"We achieved our objective by winning the group, even on a night where everything seemed to go wrong," Allegri told Rai Sport.

"We missed so many opportunities and gifted a penalty, so at the end of the day it was only right that we lost.

"[Dybala's disallowed goal] was offside. In any case, an equaliser wouldn't have changed anything at that point.

"We started well and were not lazy in our approach, things just didn't go our way, but we still won the group and I therefore thank the lads."

Dybala was left on the bench for Wednesday's encounter, but made an impressive impact with a stunning goal to set up a grandstand finish.

And although an exceptional second strike was ruled out, the Argentina international insisted Juve will learn their lessons from unexpected result. 

"I haven't seen the disallowed goal again, but the important thing is that we won the group, albeit thanks to Valencia beating Manchester United," Dybala told Rai Sport and Sky Sport Italia.

"We wasted the chances to take the lead in the first half and that gave them confidence. Once we did get two, one was ruled out, but we did react.

"The defeat hurts, because we came here looking for the win, but it should serve as a lesson for the future."