German Chancellor Angela Merkel has signalled she is willing to work with Britain on reform of the European Union, but warned it will not be "a piece of cake".
After talks with Prime Minister David Cameron at 10 Downing Street, Mrs Merkel said that the two leaders shared "a lot of common ground" on the need for change in the way the EU works and indicated that she wants action to stop freedom of movement rights being abused for benefit tourism.
The Chancellor was given the red-carpet treatment on her one-day visit to London, addressing both Houses of Parliament in the Royal Gallery of the Palace of Westminster and taking tea with the Queen at Buckingham Palace, prompting one German reporter to remark that she was being received as "the Queen of Europe".
In a speech which will be closely scrutinised for evidence of Berlin's willingness to co-operate with David Cameron's plans to renegotiate Britain's membership ahead of an in/out referendum in 2017, Mrs Merkel left no doubt that Germany wants the UK to stay in the EU.
Germany sees Britain as an "important ally" in the work of changing the European Union for the better, she told MPs and peers, adding: "We need a strong United Kingdom with a strong voice inside the European Union."
Mr Cameron said: "I want Britain to be a positive player in a reformed European Union and I know that Angela wants a strong Britain in that reformed European Union.
"My objective is clear - I want to be able to say to the British people, in a referendum that will take place by the end of 2017, that we've sufficiently reformed the EU that they should vote to stay in it. But be in no doubt, it will be an in/out referendum."
Issues to be addressed included the protection of the interests of non-euro members of the single market as the eurozone integrates, as well as "excessive interference and meddling by European institutions in our national life", said Mr Cameron.
Mrs Merkel said: "All these issues need to be addressed openly and candidly. I believe in this. It's not a piece of cake, it's going to be a lot of work, but we've already worked quite hard on other issues.
"If one wants Britain to remain in the EU - which is what I want - and if one at the same time wants a competitive Union that generates growth, one can find solutions."
In an address delivered partly in English and partly German, Mrs Merkel offered a staunch defence of the EU's record in delivering "almost half a century of peace, freedom and prosperity" and said that the 28-nation bloc - battered by the economic crisis and the instability of the euro - can still serve as "a model for other regions of the world".
The German chancellor put forward no concrete proposals for reform of the EU's rules, but accepted the need to deal with "mistakes" in the policy of free movement of EU citizens and said that "unnecessary red tape" from Brussels needs to be subject to regular reviews and scrapped when it is holding the continent back from competing globally.
And, in comments which appeared to offer encouragement to the Prime Minister's hopes of securing sufficient reform to allow him to campaign for continued EU membership, Mrs Merkel made clear that she accepts the need for the European Union to change and suggested that differences between London and Berlin may amount to no more than "details".
"Our ideas of how the future European Union ought to look like may vary on the details but we, Germany and Britain, share the goal of seeing a strong, competitive European Union join forces," she said.
Europe's politicians need " courage to bring about a change for the better", she said, adding: "We must renew Europe in keeping with the times so that it may fulfil its promise of peace, freedom and prosperity also for future generations."
With "a strong United Kingdom with a strong voice inside the European Union", she said, " we will be able to make the necessary changes for the benefit of all".
Mrs Merkel's visit to London comes at a time when the Prime Minister is coming under pressure to spell out what powers he hopes to repatriate from Brussels in the renegotiation promised if Conservatives win next year's election.
But she made clear after their 90-minute lunch that they had discussed in general terms the need for growth and jobs in Europe, rather than grappling with the "technicalities" of the precise treaty changes Britain will seek.
She joked that her speech would disappoint both those who hoped it would "pave the way for a fundamental reform of the European architecture which will satisfy all kinds of alleged or actual British wishes" and those who expected she would "deliver the clear and simple message that the rest of Europe is not prepared to pay almost any price to keep Britain in the European Union".
Mrs Merkel said that abuse of freedom of movement was "just as much of a headache for us in Germany as it is for the British people". She suggested that changes were needed either to national laws or to the EU's definition of freedom of movement in order to prevent an "onslaught" of migrants seeking access to the generous social security systems of countries like the UK and Germany.
But she insisted that the right must be upheld, telling parliamentarians: "A Europe without borders is one of the greatest achievements of European unification. All member states, all citizens benefit from this.
"But it is also true that, to maintain and preserve this freedom of movement and gain acceptance for it from our citizens, even today, we need to muster the courage to point out mistakes and tackle them."
In a highly personal speech, Mrs Merkel said that as a former citizen of socialist East Germany she was a "living witness" to the possibility of "change for the better" and recalled the pleasure of her first trip to London within months of the fall of the Berlin Wall.
She paid tribute to British troops who have served in Germany, and said that Germany was "grateful" to the UK and its other European partners for placing their trust in it following the Second World War and "the break in civilisation" represented by the Holocaust.
Speaking in the anniversary year of the outbreak of the First World War, she said: "This is a special year of commemoration for Britain, where you remember your dead, your losses and the untold suffering that Germany brought through these wars to you.
"As German chancellor, I bow my head before the victims of these horrible wars."
Mrs Merkel - who also met Deputy Prime Minister Nick Clegg and Labour leader Ed Miliband - was only the third representative of the German government to be invited to speak to both Houses of Parliament since the Second World War, following chancellor Willy Brandt in 1970 and president Richard von Weizsaecker in 1986.
Commons Speaker John Bercow said the rare honour was "amply justified", describing the German chancellor as "Europe's anchor, the essential force for stability at a time of immense turmoil and potentially catastrophic change".
She will host Mr Cameron on a return visit to Germany in just a couple of weeks' time, when he joins her to open a trade fair in Hanover.
Shadow foreign secretary Douglas Alexander said: "Chancellor Merkel's remarks have confirmed that David Cameron's approach to Europe just isn't working.
"He's lost control of his party and, as a result, he's losing influence with other European leaders.
"The gap between what Chancellor Merkel was offering, and what his eurosceptic backbenchers are demanding remains as wide as ever."