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 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.
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.
She said this had "undoubtedly" affected the progress of the Swedish proceedings.
His continued residence at the embassy and bringing him to justice had cost taxpayers £16m, she added.
"Whilst you may have had fears as to what may happen to you, nonetheless you had a choice, and the course of action you chose was to commit this offence," she concluded.
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.
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.