The King said both the UK and Germany “stand together” with Ukraine in “defence of freedom and sovereignty”.
In his toast at a lavish state banquet, which he delivered partly in German, the King promised to strengthen ties.
The speech to dignitaries from both countries, including ex-leader Angela Merkel, drew many laughs and applause.
The King’s three-day tour with Camilla, the Queen Consort, comes after a planned visit to France was cancelled following unrest in several cities over pension reforms.
Germany, due to be the second stop on the trip, is instead the location of King Charles’ first foreign visit of his reign – and the first of a British monarch since the late Queen Elizabeth II’s own state visit there in 2015.
The British government hopes the King’s visit will reinforce relations between the two nations following the UK’s decision to leave the EU – described as a “sad day” by German President Frank-Walter Steinmeier in his own toast.
At the President’s Bellevue Palace on Wednesday evening, the King said he would do everything he could to “strengthen the connections between us”.
He also heaped praise on the “generosity of spirit of the German people” for taking in more than one million Ukrainian refugees displaced as a result of the ongoing conflict with Russia.
“We stand side-by-side in protecting and advancing our shared democratic values,” he said.
“This is epitomised so clearly today as we stand together with Ukraine in defence of freedom and sovereignty in the face of unprovoked aggression.”
The King also spoke about the fight against climate change, adding: “I am utterly convinced that the connections between us will grow ever stronger as, together, we pursue a more sustainable, prosperous and secure future.”
He also mentioned his late mother, thanking the German people for the messages of “support and affection” they sent when she died last year.
“Over all these years, and in so many ways, I have been struck by the warmth of the friendship between our nations and by the vitality of our partnership in countless areas,” the King said.
“It was, Mr President, a friendship which mattered greatly to my mother, the late Queen, who cared deeply about the bond between our two countries.
“The relationship between Germany and the United Kingdom matters greatly to me… I will do all I can to strengthen the connections between us.”
In his speech the King drew laughs from guests when he referenced a British comedy sketch called “dinner for one”.
In it an elderly aristocrat dines alone while her waiter gets progressively more drunk as he consumes the alcohol poured for her missing dinner guests.
Both the King and president raised a toast at the end of their remarks, with President Steinmeier also unveiling a photograph of Charles as a child with his late father, the Duke of Edinburgh.
As a mark of respect, the couple’s plane was escorted by two Typhoon jets as it approached the airport.
From there, it was on to the ceremonial arrival at the Brandenburg Gate, the symbolic heart of Berlin. The sky was cold and grey, but the display in King Charles’ honour was intended to show the warmth of the greeting from President Steinmeier.
This was the first time in history the Brandenburg Gate had served as the backdrop to the welcome reception of any visiting head of state.
The monument is a symbol of the country’s division during the Cold War and subsequent reunification. For more than three decades, it stood just behind the wall which divided West and East Germany.
There were also splashes of colour from flags which hung around Pariser Platz – and not just German and British flags, but also conspicuously many EU flags.
And that reflected the underlying purpose of this state visit – to strengthen relations with an important European partner that might have been frayed by Brexit.
It was a formal meeting between heads of state, with military bands and tight security, but it was also a carefully choreographed piece of diplomatic theatre, delivering an image of unity in Germany’s most iconic setting.
After the flags were hoisted and national anthems were played, King Charles and President Steinmeier made their way to greet crowds of people who had lined the streets to catch a glimpse of the British monarch.
President Steinmeier described the decision to pick Germany to host the state visit as an “important gesture for German-British relations”.
In his banquet speech, he acknowledged how that relationship had changed but said “we are opening a new chapter” between the two countries.
“Our situation is different as we look to the future, yet we are doing so together,” he said.
“No matter what lies ahead, I know that our German-British friendship will remain significant and will remain firm. Our friendship is important and it is strong.”
As head of state, the King’s official visits are decided on government advice. The choice of Germany – and originally, France – as the first overseas destinations visited by the monarch will be seen as prioritising stronger relations with European neighbours.
Announcing the state visit earlier this month, Buckingham Palace said it would “celebrate Britain’s relationship” with Germany, “marking our shared histories, culture and values”.
As well as addressing what a palace spokesperson called the “sacrifices and challenges of our shared past”, the trip is intended to focus on modern challenges, including climate change and the war in Ukraine.
The King will become the first British sovereign to address the Bundestag, the German Federal Parliament, on Thursday.
King Charles and Camilla were originally due to be welcomed at a red carpet reception in the Elysée Palace in Paris on Sunday.
But the French leg of their European tour was cancelled last week after protesters planned further demonstrations over President Emmanuel Macron’s pension reforms to coincide with the visit.