McBride, 60, pleaded guilty to leaking classified defence information to journalists.
Justice David Mossop sentenced him to an aggregated five years and eight months in prison with a non-parole period of 27 months in the ACT Supreme Court on Tuesday.
McBride received a total of seven years and 11 months for three charges, but some of the sentences will be served concurrently.
The legal team wasn't expecting such a severe result, his lawyer Mark Davis said, but flagged an appeal as early as this week.
"He's in f***ing jail," he told supporters in the court room after McBride was taken into custody.
McBride won't be bailed during the appeal.
Human rights lawyers were outraged by the sentence.
"This is a dark day for Australian democracy," Human Rights Law Centre's Kieran Pender said.
Human Rights Watch's Australia director Daniela Gavshon also condemned the outcome.
"It's a stain on Australia's reputation that some of its soldiers have been accused of war crimes in Afghanistan and yet the first person convicted in relation to these crimes is a whistleblower not the abusers," she said.
Prime Minister Anthony Albanese refused to comment on whistleblower protections when asked about the case, given it was likely to be appealed.
McBride's supporters yelled out "shame" in the court room and raised their fists in solidarity while those closest to him cried when he was escorted out by officers.
McBride's former wife, Sarah, knew jail time was on the cards "but I'm in absolute shock," she said outside.
There was a significant need to deter similar actions but McBride's mental deterioration from a prison sentence needed to be considered, Justice Mossop told the court.
But his sentence was mitigated because of McBride's guilty plea, good character and potential harm prison would have on his mental health.
McBride believed soldiers were being "vexatiously" investigated for the war crime of murder to allay political concerns about the death of civilians.
"Self-confident people with strong opinions who are subject to legal duties not to disclose information must be deterred from making disclosures in order to advance their own opinions," Justice Mossop said during sentencing.
There was no "coherent argument" to back up McBride's belief he wasn't breaking the law as his defence force oath meant he was duty bound to make the disclosures, Justice Mossop said.
McBride took 235 documents - 207 of which were classified as "secret" - at defence sites and stored them in plastic tubs in a cupboard at his home.
"Unsurprisingly, this did not comply with the commonwealth government's policy on storage of information bearing the protective marking 'secret'," Justice Mossop said.
The justice accepted mental health impacted by depression and PTSD (post-traumatic stress disorder) which was self-medicated by alcohol and substance abuse "made a material, if only minor, contribution to his offending conduct".
But "the grave breach of trust involved in the offending must be taken into account", the justice said.
There was ongoing concern the leak exposed soldiers and their families to an increased risk of harm and harassment as well as possible exploitation from foreign spies, he said.
Speaking to his supporters outside court before of his sentencing, McBride said: "I did not break my oath to the people of Australia and the soldiers that keep us safe".
The leaked documents led to reports about Australian special forces soldiers committing alleged war crimes.
An inquiry later found credible information about 23 incidents of potential war crimes, which involved the killing of 39 Afghans between 2005 and 2016.