Wikileaks co-founder Julian Assange has been sentenced to 50 weeks in jail for breaching his bail conditions.
The 47-year-old was found guilty of breaching the Bail Act last month after his arrest at the Ecuadorian Embassy.
He took refuge in the London embassy in 2012 to avoid extradition to Sweden over sexual assault allegations, which he has denied.
In a letter read to the court, Assange said he had found himself “struggling with difficult circumstances”.
He apologised to those who “consider I’ve disrespected them”, a packed Southwark Crown Court heard.
“I did what I thought at the time was the best or perhaps the only thing that I could have done,” he said.
In sentencing him, Judge Deborah Taylor told Assange it was difficult to envisage a more serious example of the offence.
“By hiding in the embassy you deliberately put yourself out of reach, while remaining in the UK,” she said.
In mitigation, Mark Summers QC had said his client was “gripped” by fears of rendition to the US over the years because of his work with whistle-blowing website Wikileaks.
“As threats rained down on him from America, they overshadowed everything,” he said.
As Assange was taken down to the cells, he raised a fist in defiance to his supporters in the public gallery behind him.
They raised their fists in solidarity and directed shouts of “shame on you” towards the court.
Assange now faces US federal conspiracy charges related to one of the largest leaks of government secrets.
The UK will decide whether to extradite Assange to the US in response to allegations that he conspired with former US intelligence analyst Chelsea Manning to download classified databases.
He faces up to five years in a US prison if convicted.
Wikileaks has published thousands of classified documents covering everything from the film industry to national security and war.
At the scene
By BBC correspondent Andy Moore, at Southwark Crown Court
As Julian Assange arrived at court from Belmarsh High Security prison, photographers got a picture of him defiantly pumping his fist.
He’s still got a beard but it’s been trimmed – it’s not the white, bushy beard he was wearing when he was hauled out of the Ecuadorean Embassy last month.
There’s big international interest, and more than a dozen TV cameras outside.
Journalists had to queue for two hours before the case opened to get a ticket to Court Number One, or to an overflow court where there was a videolink to the live proceedings.
Supporters of Assange are outside court making their voices heard – one has been reading from her notes saying Assange is a political prisoner.
Assange was dramatically arrested by UK police on 11 April after Ecuador abruptly withdrew its asylum.
At a court hearing that same day, he was remanded in custody and called a “narcissist who cannot get beyond his own selfish interest” by district judge Michael Snow.
Days later, Swedish prosecutors said they were considering reopening the investigation into rape and sexual assault allegations against him.
At the time, Assange said he had had entirely consensual sex with two women while on a trip to Stockholm to give a lecture.
Prosecutors dropped the rape investigation in 2017 because they were unable to formally notify him of allegations while he was staying in the embassy.
Two other charges of molestation and unlawful coercion had to be dropped in 2015 because time had run out.
More than 70 UK MPs and peers have signed a letter urging Home Secretary Sajid Javid to ensure Assange faces authorities in Sweden if they want his extradition.