Cristiano Ronaldo had done his work when he was substituted in the 72nd minute of another tough Champions League evening for Manchester United in Switzerland on Tuesday.

Ronaldo had scored an early goal — a record-extending 135th in the competition — then forced the Young Boys' goalkeeper to save a stinging shot and almost earned a penalty after breaking clear when the score was still 1-0 early in the second half.

It was 1-1 when he was replaced by Jesse Lingard as United — playing defensively after a red card in the 35th minute for defender Aaron Wan-Bissaka — withstood increasing pressure from the unheralded Swiss champion roared on by most of a noisy 31,120 crowd.

But there was a late twist as Lingard's misplaced back pass deep into stoppage time teed up a current United States forward — who was sent on by the former U.S. international who coaches Young Boys — to settle the game with almost the last kick.

Jordan Pefok pounced on the loose ball behind the United defense to shoot past goalkeeper David De Gea, handing United a shock 2-1 loss and giving coach David Wagner a stellar start to his first Champions League campaign.

READ | We're not even a team yet: PSG manager Pochettino

“This is something absolutely extraordinary," Wagner said, though adding “we have to say it was deserved.”

Pefok's goal came from Young Boys' 19th effort on goal, compared to two for United — both from Ronaldo — and none after the 24th minute.

Asked why he removed his 36-year-old superstar from the action, United coach Ole Gunnar Solskjaer said “he’s exceptional but we have to look after him as well.”

“It felt like the right moment to take him off,” Solskjaer said, noting that the Swiss champion's artificial surface — the only plastic pitch of the 32 Champions League teams this season — “takes its toll as well.”

It all added up to a third group-stage loss for Manchester United in Switzerland in the past decade after two defeats at Basel.

Both coaches cited Wan-Bissaka's red card as a game-changer. His cleat went through the ball in a challenge on Christopher Martins deep in the Young Boys half.

“It was never reckless or malicious but probably a little bit inexperienced to go through there," Solskjaer said.

ALSO READ | Lazio manager Maurizio Sarri handed two-match ban

Ronaldo’s goal in the 13th minute was created by Bruno Fernandes’ clever pass with the outside of his right foot into the path of his Portugal teammate for a low shot that squirmed under goalkeeper David von Ballmoos.

Young Boys deservedly leveled in the 66th when midfielder Nicolas Moumi Ngamaleu met a low and deflected cross into a crowded goalmouth with a shot that beat De Gea at his near post.

Ronaldo claimed a share of more Champions League history just by playing his first United game in the competition since the 2009 final.

His 177th career appearance in the Champions League proper tied the record held by Iker Casillas, his longtime teammate at Real Madrid. Both Ronaldo and Casillas have played an extra four games in qualifying rounds.

Those Champions League qualifying rounds seemed to have prepared Young Boys well for facing a star-studded Manchester United team playing just its fifth competitive game of the season.

The Swiss team was sharp and physical in its 13th game of a season that started in mid-July with the first of six Champions League qualifiers.

ALSO READ | CAF president urges 'open minded' debate on World Cup every two years

“We always knew that they are a high intensity, energetic, athletic team.” Solskjaer said, noting his team's failure to create more counterattacks after Raphaël Varane came on for the second half to steady the defense.

Solskjaer also lamented a penalty kick not given by French referee Francois Letexier when Ronaldo had broken clear of Young Boys defender Mohamed Ali Camara in the 54th.

“That’s what sometimes you get with young refs,” the Manchester United manager said, suggesting Letexier ”probably didn’t dare do it because he had to send (Camara) off then."

Still, the later result in Group F was favourable with Villarreal and Atalanta drawing 2-2 in Spain.

Man United hosts Villarreal on September 29 — a rematch of last season’s Europa League final that it lost. Atalanta hosts Young Boys on the same day.