EU leaders have chosen the Belgian Prime Minister, Herman van Rompuy, to be the first permanent European Council President.
The other top job created by the Lisbon Treaty - foreign affairs supremo - has gone to the EU Trade Commissioner, Baroness Catherine Ashton from the UK.
Both are seen as consensual politicians with little foreign policy experience.
Both had unanimous backing from the 27 EU leaders at the summit in Brussels, UK Prime Minister Gordon Brown said.
Earlier, the UK government said it was no longer pushing for former PM Tony Blair to get the presidency post.
Mr Van Rompuy had crucial French and German support. He has a reputation as a coalition builder, having taken charge of the linguistically divided Belgian government and steered it out of a crisis.
"Every country should emerge victorious from negotiations," he told a news conference after his appointment.
"Even if unity remains our strength, our diversity remains our wealth," he said, stressing the individuality of EU member states.
UK shifts stance
A UK government spokesman revealed the dramatic twist in the British position.
The UK persuaded the other six leaders in the socialist group to back the Baroness Ashton, having dropped Tony Blair.
The EU leaders met in Brussels to select their first full-time president and the High Representative for Foreign Affairs - new posts created by the Lisbon Treaty, which will come into force on 1 December.
Mr Brown praised Mr Van Rompuy as "a consensus builder" who had "brought a period of political stability to his country after months of uncertainty".
"I am particularly pleased that a Briton secured the other position. It gives Britain a powerful voice within the Council and the [EU] Commission. It will ensure that Britain's voice is very loud and clear. It will ensure that Britain remains at the heart of Europe," he said.
Baroness Ashton "is the first woman to hold such a high position in the EU," he added.
Commenting on the choice, European Commission President Jose Manuel Barroso said "it's so important that Britain remains at the heart of the European project".
Going into the meeting the heads of the 27 EU member nations had various candidates to choose from and after-dinner negotiations were expected to continue late into the night.
Mr Blair had been an early favourite for president and was the highest-profile candidate.
Another contender, Dutch PM Jan-Peter Balkenende, ruled himself out of the contest as the meeting got under way.
The EU leaders had a working dinner together to negotiate the appointments.
They were reported to be striving for a balance in the two posts, with one filled by a candidate from one of the bigger EU states, the other from a smaller country.
Similarly, the presidency was expected to go to a centre-right politician and the post of foreign affairs chief to the centre-left.
The combination of Mr Van Rompuy and Lady Ashton achieves that balance, the BBC's Jonny Dymond says.
Mr Barroso said Mr Van Rompuy's appointment was "a tribute to Belgium," noting Belgium's key role as host of the EU's main institutions.
Mr Blair was an early frontrunner for the presidency, but some leaders feared he would overshadow them and so the mood shifted in favour of a lower-profile name instead, the BBC's Europe editor Gavin Hewitt says.
The EU president will chair regular meetings of the European Council at which decisions are taken about the political position of the bloc.
However, correspondents say the High Representative for Foreign Affairs and Security Policy, as the post is officially known, could have an even more powerful role.
The foreign policy chief will have a seat as vice-president of the European Commission, as well as a budget worth billions of euros and a new diplomatic service of up to 5,000 people.
Mr Van Rompuy has been described as a pragmatic rather than a charismatic figure.
During his time as budget minister in Belgium's Christian Democrat-led government, he took a tough stance on balancing the economic books, drastically reducing the country's public debt.