Boxer Joe Joyce became the UK's 67th and final medalist of the 2016 Olympic Games last night as the traditional Closing Ceremony at the Maracana Stadium brought down the curtain on Rio 2016.

It completed an extraordinary 16 days for the British team here, exceeding the record haul of medals accumulated in London four years ago with 27 golds, 23 silvers and 17 bronzes, and making the nation the first ever to win more at an away Games immediately after acting as the hosts - ending up second to the USA in the overall medal table.

Among the roll of honour were 13 Scots, with athlete Eilidh Doyle the last to step on to a podium as part of the GB&NI 4x400 relay team late on Saturday night, moments after Mo Farah had picked up the fourth gold of his career in the 5000 metres final.

However, Joyce could not quite provide the perfect sign-off, with the 30-year-old forced to settle for Olympic super-heavyweight silver on a controversial split decision with France's Tony Yuka.

The 30-year-old, emboldened by a war of words with his rival ahead of the bout, kept jabbing away in his bid to follow Anthony Joshua and Audley Harrison in lifting this title. But most observers were left stunned as Yuka prevailed on points – with Joyce left as a footnote in British Olympic history.

"I was working him to the body and working him to the head and I thought I was penetrating his guard," he said. "Maybe towards the end of a round, he would nick a few shots but the majority of the world was done by me.

"I'd prefer to be Olympic champion. I thought I was landing a lot of shots long range and then I was going in close and hitting him there too. I thought I won the rounds and I will have to watch that back and get a clearer opinion but I thought I did enough to win the gold medal. I thought I took it to him and I'd be coming back over the moon. People remember a gold medalist a lot more. But we have beaten our target and beaten London."

It left the British squad with medals in 18 of the 23 sports they entered here, topping the sport standings in cycling, rowing, triathlon and sailing.

As for Doyle, the die was cast the moment she packed her bags and took the long road south from Perthshire to Bath, her teaching job wiped like chalk on a blackboard as she threw everything into her quest to excel. Family, friends, the boyfriend who would one day become her husband, all becoming long-distance relationships so that the Scot could pursue the impossible at the expense of the comfortable.

And now, sacrifices have delivered the reward the Scot craved. At 29, Doyle is now an Olympic medallist, the weighty bronze gong hanging around her neck in the wee small hours of yesterday morning the return on an investment that began in her teens and paid out as she pulled off a solid opening leg in the 4x400m relay final in Rio before, in turn, Anyika Onuora, Emily Diamond and then Christine Ohuruogu took the British team over the line in third behind the USA and Jamaica.

Of course, the Scot would have wished her turn on the podium had come 48 hours earlier when she entered the 400m hurdles final with some hopes of first but exited last. But a prize is a prize and there are only two better than this, coloured silver and gold.

“It just feels absolute joy,” said Doyle, the first Scottish athletics medallist since Liz Lynch in Seoul, barely 18 months after she was born. “It’s something different. I’ve won world medals. I’ve won European and I’ve won Commonwealth. But there’s something every very special about an Olympic medal. That’s the one you always want.

“I’ve added that to the collection now so I’ve got one from each championships. I can now go home a happy girl. You take it for granted because it’s all a whirlwind after you win a medal. These are the moments that you train for – to be able to do a lap of honour and to be able to share it with the girls as well, these are the moments you want more of all the time. So I was really trying to savour it.”

And she wants more after a year in which her Scottish hurdles record has been scythed and she added a European gold to a now-expanded haul. Retirement remains a while away, even if her coach Malcolm Arnold is stepping away from the daily fray.

“As soon as you get to this age, to about 30, people start talking about how long you’ll keep going for, when you’ll retire,” she confirmed. “I just got married so people are talking about when you’ll stop and have a family. But I can’t imagine stopping. Because I love what I do. Yes, there are low points but when you get to a point like this, you forget about them all.”

It came moments after an equally spectacular outing from fellow Scot Andrew Butchart who ended up sixth in the 5000 metres after a flurry of disqualifications and protests.

Mo Farah secured a second gold in Rio to add to the victory he claimed in the 10,000m, following in the footsteps of the Flying Finn Lasse Viren with a double-double by repeating both triumphs from London 2012. However the Perthshire prospect, who was briefly elevated to fourth, lowered his Scottish record to 13:08.61 with a performance that showed both talent and maturity, with Farah playing a small but critical role.

“We spoke before the race and sat on the bus together coming down,” Butchart revealed. “He’s such a relaxed person that you feed off it and that makes you more relaxed and not as nervous. I am happy with the time. The placing was more important than the personal best. I’m just so happy that I did that.”

Lynsey Sharp also reduced her Scottish record in the 800m final but came sixth as controversial South African Caster Semenya surged to gold.

“The thing that I’m most happy about this week is to get through the rounds clean,” said the 26-year-old, who ran a time of 1:57.69. “It was a disappointment last year [when she failed to make the world championships final] and it’s actually harder to make the final than to run in the final. So I was just very happy to make the final and do myself justice.

"It was very competitive. I ran the fastest I've ever run in an Olympic final. I know I can go faster but I'm still happy with that performance."

Asked about Semenya and the issue of which testosterone levels should be allowed, Sharp added: "I have tried to avoid the issue all year. You can see how emotional it all was. It is out of our control. We rely on people at the top sorting it out. The public can see how difficult it is with the change of rule, but all we can do is give it our best."