Guinea's President Alpha Condé has won a controversial third term in office, preliminary results show, amid violent protests across the country.
The electoral commission said the 82-year-old had taken 59.5% of the vote. The victory still requires confirmation by the Constitutional Court.
His opponent, Cellou Dalein Diallo, said he would contest the result, alleging large-scale fraud.
At least 30 people have died since the vote on Sunday, Guinean media report.
Mr Diallo, 68, won 33.5% of the ballots, the electoral commission said.
"We are still going to refer the matter to the constitutional court, without having too many expectations," Mr Diallo told Agence France-Presse.
The president says a constitutional referendum in March allowed him to run despite a two-term limit, but opponents say he is breaking the law by holding on to power.
Dozens have been killed in the months after Mr Condé said he would re-run. There are fears of further ethnic clashes if the results are disputed.
What's the latest in the protests?
Gunfire erupted in the capital, Conakry, on Friday. According to sources contacted by the BBC, the army has been called in to support the police in maintaining order.
Three police officers died in clashes on Friday, according to Guinean media.
Communications by telephone are barely going through and the internet has been shut down.
Witnesses told Reuters news agency there had been gunfire in the Sonfonia neighbourhood of Conakry and a local resident said police had used warning shots to break up protests.
Residents in opposition strongholds say that many people are holed up in their homes and that the police are using live ammunition instead of tear gas against protesters.
Five things about Guinea:
Independence leader Sékou Touré told France in 1958: "Guinea prefers poverty in freedom than riches in slavery"
"Black power" civil rights leader Stokely Carmichael moved from the US to Guinea in 1968, with his then-wife, the singer Miriam Makeba, becoming a life-long proponent of pan-Africanism
It has the world's biggest reserves of bauxite - the main source of aluminium
Its Mount Nimba Strict Nature Reserve, a Unesco World Heritage Site, is known for its viviparous toad and chimpanzees that use stones as tools
Singer Mory Kanté, famous for the 1980s hit Yéké Yéké, came from a well-known Guinean family of griots, or praise-singers
Who is Alpha Condé?
Mr Condé was a veteran opposition leader who finally won elections in 2010, marking the first genuinely democratic handover in Guinea since independence.
He served jail time for challenging Gen Lansana Conté, who ruled from 1984 to his death in 2008.
He campaigned on his economic record and prospects that Simandou, one of the world's largest untapped iron-ore deposits, might finally be exploited - creating thousands of jobs.
But critics say that any economic growth has not filtered down to the bulk of the population. Power cuts are common and many young Guineans are unable to find work.
A new constitution was approved in a referendum in March. Mr Condé argues this means he is allowed to seek re-election, even though he had already served the maximum of two terms allowed under the previous constitution.
The opposition disputes this and street protests have led to dozens of deaths over the past year.
Who is his main challenger?
Cellou Dalein Diallo a former prime minister, is the only formidable opponent. He lost to Mr Condé in both 2010 and 2015, although he says both elections were marred by widespread fraud.
He is a member of the Peul, or Fulani, community. Although they are Guinea's largest ethnic group, the country has never had a Peul president and many ethnic Peuls say they have faced discrimination, dating back to the days of President Sékou Touré, when thousands fled the country.
Mr Condé is largely backed by members of his Malinké community, as well as the country's third major ethnic group, the Soussous.
Mr Diallo and other opposition figures in the National Front for the Defence of the Constitution (FNDC) had vowed to boycott an election which they felt could never be fair.
But in early September, Mr Diallo broke with the FNDC, announcing that he would run after all.
The FNDC has called for nationwide protests from Monday.