South Sudan has become the world’s newest nation, the climax of a process made possible by the 2005 peace deal that ended a long and bloody civil war.
Sudan’s President Omar al-Bashir and UN Secretary General Ban Ki-moon are among international dignitaries attending celebrations in the capital, Juba.
Sudan earlier became the first state to officially recognise its new neighbour.
The south’s independence follows decades of conflict with the north in which some 1.5 million people died.
Celebrations in Juba began at midnight (2100 GMT). A countdown clock in the city centre reached zero and the new national anthem was played on television.
South Sudan became the 193rd country recognised by the UN and the 54th UN member state in Africa.
Officials had planned for people to hold quiet celebrations at home, with the formal declaration of independence due later on Saturday.
But the people clearly couldn’t wait. Two hours before midnight and lines of cars zoomed around town packed with people waving flags and waiting to celebrate.
When the final countdown arrived, the atmosphere was wild. Groups ran down roads, dancing to drum beats. Soldiers and policemen joined in too, waving paper flags and laughing.
A sign read: “Congratulations, free at last, South Sudan.” But the people didn’t need to read the message – they were already dancing and leaping with happiness.
“It is a shout of freedom,” said Alfred Tut, lifting his head back and screaming.
The BBC’s Will Ross in Juba says the new country’s problems are being put aside for the night, and there is an air of great jubilation.
People are in the streets, cheering, waving South Sudan flags, banging drums and chanting the name of President Salva Kiir Mayardit, he adds.
A formal independence ceremony is due to be held later on Saturday.
The Speaker of the South Sudan Legislative Assembly, James Wani Igga, is expected to read out the Proclamation of the Independence of South Sudan at 1145 (0845 GMT). Minutes later Sudan’s national flag will be lowered and the new flag of South Sudan will be raised.
In addition to Mr Bashir and Mr Ban, attendees will include former US Secretary of State Colin Powell, the US permanent representative to the UN, Susan Rice, and the head of the US military’s Africa Command, Gen Carter Ham.
Under the Comprehensive Peace Agreement, a referendum was held on independence, which was favoured by more than 99% of voters.
The new country is rich in oil, but one of the least developed countries in the world, where one in seven children dies before the age of five.
Unresolved disputes between the north and south, particularly over the new border, have also raised the possibility of renewed conflict.
On Friday, Sudan’s Minister of Presidential Affairs, Bakri Hassan Saleh, announced that it recognised “the Republic of South Sudan as an independent state, according to the borders existing on 1 January 1956”, when Sudan gained independence from Britain.
Facts and figures:
- Population: 7.5-9.7 million
- Size: 619,745 sq km (239,285 sq miles), larger than Spain and Portugal combined
- Major languages: English, Arabic (both official), Juba Arabic, Dinka
- Religion: Traditional and a Christian minority
- Main export: Oil
- One of world’s least developed countries: Worst maternal mortality rate; most children below 13 not in school; 84% of women are illiterate
- Relations with Sudan: Dividing debts and oil; border disputes; citizenship
- Security: At least seven active rebel groups
President Bashir, who agreed the 2005 peace deal with the Sudan People’s Liberation Army (SPLA), stressed his country’s “readiness to work with our southern brothers and help them set up their state so that, God willing, this state will be stable and develop”.
“The co-operation between us will be excellent, particularly when it comes to marking and preserving the border so there is a movement of citizens and goods via this border,” he told journalists in Khartoum.
Fears of fresh conflict resurfaced after recent fighting in two border areas, Abyei and South Kordofan, which forced some 170,000 people from their homes.
But separate deals – and the withdrawal of rival forces from the border – have calmed tensions.
The UN Security Council has passed a resolution approving a new 7,000-strong peacekeeping force for South Sudan – but this is basically a rebranding of the force which was already in Sudan, mostly in the south.
Khartoum has said its mandate would not be renewed, leading the US to argue that the 1,000 UN troops should be allowed to remain in South Kordofan. The 1,000 troops in the disputed town of Abyei are to be replaced by 4,200 Ethiopian soldiers.
Our correspondent says keeping both the north and the south stable long after the celebratory parties have ended will be a mighty challenge.
Click to play
All you need to know about South Sudan’s independence
The two sides must still decide on issues such as drawing up the new border and how to divide Sudan’s debts and oil wealth.
Analysts say the priority for Khartoum will be to negotiate a favourable deal on oil revenue, as most oilfields lie in the south. At present, the revenues are being shared equally.
Khartoum has some leverage, as most of the oil pipelines flow north to Port Sudan on the Red Sea.
Citizenship is also a key issue which has not yet been decided.
A new law passed by the National Assembly in Khartoum has withdrawn Sudanese citizenship from all southerners.
The UN refugee agency (UNCHR), has urged both governments to prevent statelessness.
The great divide across Sudan is visible even from space, as this Nasa satellite image shows. The northern states are a blanket of desert, broken only by the fertile Nile corridor. South Sudan is covered by green swathes of grassland, swamps and tropical fo