Media playback is unsupported on your device Media caption "We know division in Europe is dangerous and we must guard against it"

The Queen has spoken of the need for unity in Europe in a speech to German and UK leaders in Berlin.

The monarch, who is on a four-day trip, said "division in Europe is dangerous".

Her speech was made in the presence of German Chancellor Angela Merkel and Prime Minister David Cameron, who wants to reform the UK's EU membership.

Buckingham Palace stressed the comments were not about Mr Cameron's EU aims - but campaign group Republic criticised her "intervention in politics".

Ms Merkel and Mr Cameron earlier met for talks ahead of an EU summit in Brussels.

'Common endeavour'

The Queen, who as UK head of state stays politically neutral, told the banquet in Bellevue Palace, the official residence of Germany's president Joachim Gauck: "In our lives, we have seen the worst but also the best of our continent.

"We have witnessed how quickly things can change for the better.

"But we know that we must work hard to maintain the benefits of the post-war world.

"We know that division in Europe is dangerous and that we must guard against it in the west, as well as in the east, of our continent. That remains a common endeavour."

Analysis by Peter Hunt, BBC royal correspondent

Image copyright AP

Two heads of state - one elected, one hereditary - delivered two rather different speeches.

Germany's President Gauck had no difficulty echoing the position of his prime minister that they would assist Britain in order to keep her in Europe.

The Queen - who her aides insist is apolitical - wasn't there to actively and openly assist David Cameron in his bid to renegotiate the UK's EU membership.

Those around her say the British monarch's words were about Europe, not the EU.

She was able to draw on her personal wartime experience to highlight the advantages of unity and the perils of division.

There's no denying the content was pro-European; this was a British head of state highlighting the value of her country's place at the heart of the continent.

Such words won't harm if, when the time comes, David Cameron decides to back a Yes vote in the in/out EU referendum.

More from Peter Hunt

Later a Buckingham Palace aide said: "This is not about the EU. The Queen is apolitical. She would never make a political point."

However, Campaign group Republic claimed the Queen's comments fitted "a recent pattern of intervening and then having the palace deny it is an intervention".

Republic CEO Graham Smith said: "It's a dishonest and underhand pattern of interventions that is the result of the Queen being unaccountable for what she does."

He said she appeared to be "dancing to the PM's tune", but added: "If David Cameron thinks getting the Queen on side is going to help his cause he is playing with fire.

"An outspoken monarch is a much easier target for a growing republican campaign."

Robert Lacey, a historian and biographer of the Queen, said he thought it was clear the Queen's speech had been written "from her own experience" of living through World War Two and visiting the country 20 years after the war ended.

Image copyright PA Image caption The banquet was hosted by Germany's president Joachim Gauck

He said the first draft of the speech was likely to have been written by the Queen and her advisers and then run past government officials.

There was also a "huge Nato dimension" to her talk, he added, with the "east" she spoke of clearly referring to Ukraine.

The Palace aide said the Queen had been referring to risks of wider differences dividing the continent.

Mr Gauck said in his banquet speech that the EU needed the UK and it would support a "constructive dialogue" on the reforms Mr Cameron wanted.

He said the EU was facing "major challenges" and that "an effective European Union" was "based on a stable foundation of shared values".

"A constructive dialogue on the reforms Britain wants to see is therefore essential," he said.

"As a good partner, Germany will support this dialogue. For Britain is part of Europe. The European Union needs Britain.

"A united Europe, a strong European Union, represent stability, peace and freedom - for us all."

Mr Cameron has said he wants to reform the UK's membership of the EU before holding an in/out referendum in 2017.