The Russian opposition leader made the comments in the first of two court hearings on Saturday - in the second, a defamation case, he was ordered to pay a fine of 850,000 rubles (about £8,200).
The 44-year-old was arrested on 17 January as he returned to Russia from Germany, where he had spent five months recovering from a nerve-agent poisoning that he blames on the Kremlin - an allegation denied by Russian authorities.
His sentence stems from a 2014 embezzlement conviction that he has rejected as fabricated and the European Court of Human Rights (ECHR) has ruled to be unlawful.
Mr Navalny had asked Moscow City Court to overturn the sentence and set him free.
On Saturday morning, the court rejected his appeal - despite an order by the European rights court to free him - but did shorten his original jail term by six weeks.
The original sentence was 3.5 years but, with the amount of time he has already spent under house arrest, amounted to around two years and eight months.
Mr Navalny reportedly responded sarcastically to the ruling. "They've reduced the sentence by 1.5 months. Great!" he said, according to the Reuters news agency.
Speaking about why he was unable to report to the Moscow prison service in 2020, he reminded the court he had been recovering in Germany.
"I don't want to show off a lot, but the whole world knew where I was," Mr Navalny told the judge. "Once I'd recovered, I bought a plane ticket and came home."
Despite his imprisonment, he said he had no regrets about returning to Russia. "Our country is built on injustice," he said. "But tens of millions of people want the truth. And sooner or later they'll get it."
In the second hearing on Saturday, Mr Navalny was convicted on charges of slandering a 94-year-old Second World War veteran. He allegedly called the veteran and other people featured in a pro-Kremlin video last year "corrupt stooges", "people without conscience" and "traitors".
Rejecting the charges, he described them as another example of official efforts to disparage him.
Since Mr Navalny was detained early this year, there have been large anti-Kremlin protests across Russia calling for him to be released, and many of his supporters have been detained.
Diplomats from several European countries were expelled from the country for allegedly joining the demonstrations - a move that was criticised by the UK's foreign secretary Dominic Raab.
Several Western countries have condemned the case and are discussing possible sanctions on Russia.
Earlier in February, Russia's foreign minister Sergei Lavrov described the reaction as "hysteria".
Analysis: This is a David v Goliath fight - but it's hard to see even jail ridding Navalny of his determination
by Diana Magnay, Moscow correspondent
The die was cast on the outcome of these court hearings before they'd even begun.
This was punishment for returning to his homeland and for generating a swell of anti-Putin protest. This was punishment for surviving a novichok poisoning and having the audacity to come back and challenge his would-be killers on it.
It is likely the last that we will see of Alexei Navalny for a while. Although there is another embezzlement charge in the works, which itself carries a possible 10-year jail sentence, the Kremlin has likely had enough of his defiant courtroom denunciations and investigators may take their time "accumulating" their evidence.
By jailing him, the intention is to put him out of sight and out of mind. That's despite the ECHR's demands that he be released immediately and a possible further round of EU sanctions.
Mr Navalny's team is determined not to let his cause slip from the public eye and has called for further protests later in the spring ahead of the big political fixture this year, parliamentary elections in September. The state is waging criminal prosecutions against them too.
This is a David versus Goliath fight. As Nelson Mandela said: "When people are determined they can overcome anything."
It is hard to see even jail ridding Alexei Navalny of his colossal determination.