East Timor has officially been declared independent at a colourful and emotional ceremony in the capital, Dili, marking an official end to 450 years of foreign rule over the territory.
Independence... As a people, as a territory, as a nation... One body, one mind, one wish!
After the United Nations Secretary General Kofi Annan handed over authority to the new government, the newly-installed President Xanana Gusmao thanked the international community for its support in ending Indonesian rule.
Mr Gusmao, a former guerrilla leader, said that those present at the inauguration were witnesses to the desire of all people for independence and to the struggle against poverty in all its forms.
In what was described as an important sign of reconciliation to the visiting Indonesian President Megawati Sukarnoputri, Mr Gusmao spoke in Indonesian, as well as in English and Portuguese, the language of the formal colonial power.
"We warmly welcome your presence here among us, not only in your capacity as the head of state of the brotherly and neighbouring country... but also as a symbol of the democratic journey of the brotherly people of Indonesia," he told President Megawati.
Wearing a traditional Timorese scarf, the new president paid tribute to the "bravery" of former Indonesian President Habibie.
Mr Gusmao also thanked Australian Prime Minister John Howard and former President Bill Clinton - both of them present at the ceremony - for their support in East Timor's struggle for independence.
'Day of pride'
East Timor voted for independence from Indonesia in 1999, and the territory has been under UN administration ever since.
The new flag now flies over East Timor
"Independence! As a people, as a territory, as a nation! One body, one mind, one wish!" said President Gusmao as fireworks lit up the sky.
But he warned: "Our independence will have no value, if all the people in East Timor continue to live in poverty and continue to suffer all kinds of difficulties."
Former colonial power Portugal, whose president and prime minister were at the ceremony, pledged more money for the reconstruction of East Timor, which is Asia's poorest country.
Before the UN flag was lowered, Mr Annan said he was "proud of the partnership" between the UN and the people of East Timor.
"It's a day of pride for all of us," he said.
Earlier, hundreds of worshippers attended morning mass at the house of the Bishop of Dili, Carlos Belo.
East Timor key facts:
Population of 800,000
Asia's poorest country
Languages include Tetum, Portuguese and Indonesian
90% Roman Catholic
His home was recently rebuilt after being burnt down by the pro-Indonesian militias that went on a rampage after the independence referendum.
"The spirit within us has emerged and, with that spirit, we can shine and stand alone," said Bishop Belo.
"We celebrate this day of independence by thanking God. If God had not been with us, we could not have achieved it. We could not have survived," he said in his sermon.
Foreign Minister Jose Ramos Horta - who was also at the service and was awarded a Nobel Peace Prize with Bishop Belo in 1996 - endorsed the religious leader's words of peace.
He said his message for independence was "tolerance and forgiveness."
The independence ceremony was accompanied by a cultural programme of singing and dancing.
Vendors sold the new national flag and Independence Day T-shirts.
UN success story
After his arrival in Dili, Mr Annan said peace-keeping forces would gradually pull out, but the UN would remain engaged and would continue to support an independent East Timor.
The BBC's Jonathan Head in Dili says the statement was intended to reassure the Timorese - many of whom felt abandoned by the international community during the Indonesian occupation.
Bishop Belo has been praying for peace
Our correspondent says East Timor has been a success story for the UN.
In less than three years, it has helped the shattered country to stand on its own feet and, despite the challenges ahead, that sense of achievement dominates the festivities.
As well as the need to overcome chronic poverty, correspondents say much of East Timor's future depends on relations with its giant neighbour, Indonesia.
About 200,000 East Timorese are thought to have died under Indonesia's occupation of the former Portuguese colony.
But the presence of President Megawati at the ceremony has been interpreted as an encouraging start.
She was greeted with a roar of applause by the crowd, as she joined hands with Xanana Gusmao.