“It was not for you to decide the nature of your cooperation with the Swedish investigation,” Judge Deborah Taylor said as she delivered the verdict at the Southwark Crown Curt in London.
“You exploited your privileged position to flout the law and advertised internationally your disdain for the law of this country.”
The Australian whistleblower, who was arrested on April 11 after Ecuador gave him up, raised a clenched fist as he arrived in a prison van at the court.
Assange fled to the Ecuadorian embassy in 2012 after a British judge ordered his extradition to face Swedish allegations of sexual assault and rape, which he strongly denied.
He claimed the allegations were a pretext to transfer him to the United States, where he feared prosecution over release by WikiLeaks of millions of classified documents.
There is no longer an active investigation in Sweden and the extradition request has lapsed.
However, the 47-year-old is facing a US extradition request, which was only revealed following his dramatic arrest, when he was dragged shouting from the embassy by police.
In her judgement, Taylor rejected Assange's lawyers argument that he had been living in prison conditions at the embassy, telling him that he could have left the building “at any time” and had cost the British taxpayer £16m by remaining in the embassy.
His behaviour, she said, justified the highest possible sentence for breaching bail, adding that it was “difficult to think of a more serious example of this offence”.
- Assange will cooperate with Sweden, but fight US warrant: lawyer
- Timeline: The key points in the Julian Assange case
- British MPs urge cooperation with Sweden in Assange case
- Assange finally faces Swedish rape questions
At the end of the trial, Assange submitted a letter to Taylor in which he apologised for his decision to seek asylum, saying he had found himself “struggling through terrifying circumstances”. “I did what I thought was best at the time,” he wrote.
His lawyer Mark Summers told the court in his summing up, that Assange in 2012 had been preoccupied by the fear that he would be extradited to the United States where he feared being sent to the Guantanamo Bay prison camp and tortured.
“By the time he was arrested, Mr Assange was living in overwhelming fear of being extradited to the US. These threats overshadowed everything,” he said.
Summers said that Assange had initially tried to cooperate with Swedish prosecutors over the two accusations, adding that after he was finally interviewed in the Ecuadorian embassy in 2016, the charges were dropped.
Assange's supporters have dwindled significantly since he first entered the embassy, with just over a dozen outside the courtroom on Wednesday and a similar number inside.
But they were nonetheless a noisy presence, groaning in the courtroom when the defence spoke of the possibility of Assange's extradition to the US, and chanting outside on the steps of the courtroom.