Iran, the Middle East's second largest power by economy and population, is the Shiite Muslim rival of regional Sunni giant Saudi Arabia.
Second biggest economy
Iran has the region's second largest economy after Saudi Arabia. With 79.11 million inhabitants (2015, World Bank), it is also the second most populous country in the Middle East, after Egypt.
A founding member of OPEC, it has the world's fourth-biggest oil reserves and the second-largest gas reserves, after Russia.
In 2014, income per capita was $6,550.
Some economic sanctions imposed on Iran over its nuclear programme have been lifted since mid-January 2016, allowing Tehran to resume oil exports and pick up trade with the European Union.
However, the fall in the price of crude has weighed on the economy.
Unemployment officially stands at 12.5 per cent, including 27 per cent of young people -- which analysts say is an understatement -- and foreign investment is only trickling in.
Shia Muslim power
Iran has an area of 1,648,195 square kilometres (659,278 square miles).
The descendant of the Persian Empire, it was long a monarchy ruled by a shah and dominated by the Pahlavi dynasty from 1925 to 1979.
In January 1979, shah Mohammed Reza Pahlavi was driven out by a popular revolt. Ayatollah Ruhollah Khomeini, a revolutionary cleric who had lived in exile for a decade and a half, made a triumphant return on February 1.
The shah's government fell 10 days later when public radio announced "the end of 2,500 years of despotism".
An Islamic republic was proclaimed on April 1.
Between 1980 and 1988 Iran fought a war with Iraq in which more than a million people were killed.
Rivalry with Saudis
For centuries, Shiite-majority Iran has competed with Turks and Arabs for regional supremacy. Currently, its main rival is Sunni heavyweight Saudi Arabia.
The two countries have taken opposing sides in wars in Syria and Yemen.
In Syria, Tehran backs the regime of President Bashar al-Assad, a member of the minority Alawite community, against Sunni rebels supported by Riyadh.
In Yemen, Saudi Arabia fights in support of pro-government forces against Iran-backed rebels and their allies.
Conservatives, reformers, moderates
After Khomeini died in 1989, Ayatollah Ali Khamenei, president since October 1981, became supreme leader.
Moderate conservative Akbar Hashemi Rafsanjani was elected president and orchestrated economic reforms.
After eight years of rule by reformist president Mohammad Khatami (1997-2005), hardliner Mahmoud Ahmadinejad took office in 2005. His re-election in June 2009 sparked a massive political crisis and a crackdown on nationwide protests that decimated the reformist movement.
Historic nuclear accord
After taking office on August 3, 2013, President Hassan Rouhani, a moderate cleric, relaunched formal negotiations with major powers on Iran's nuclear programme.
An historic accord was signed on July 14, 2015 and implemented on January 16, 2016, bringing a 13-year-long dispute to a close.
Terms of the accord stipulate that Tehran will not try to build a nuclear bomb, an ambition it has always denied. In exchange, many international sanctions were lifted although remaining US sanctions continue to stifle trade.
The highest political authority is the supreme leader, who has the final say on all national issues.
The president, elected for four years by universal suffrage, nominates the government.
The Assembly of Experts is a body of elected clerics that oversees the functions of the supreme leader. Constitutionally, it has powers to select and even dismiss the leader.
Parliament's powers are limited when compared to other institutions, and it is vetted by the Guardian Council.
The Expediency Council is Iran's top political arbitration body, tasked with resolving disputes between parliament and the Guardian Council and of advising the supreme leader.
The Revolutionary Guards are the elite arm of the country's military, and deeply embedded in Iranian political and economic life.
A primer on this year's election
Over 1,600 Iranians, of which 100 were women, threw their hats in the ring to be the next president. The Guardian Council whittled down the list to six candidates, none of whom were women.
The shortlisted names were incumbent President Hussain Rouhani, incumbent vice president Eshaq Jahangiri, Ebrahim Raisi, Mohammad Bagher Ghalibaf, Mostafa Mir-Salim and Mostafa Hashemitaba.
Ghalibaf and Jahangiri have dropped out in the last two days, leaving four candidates for the country's presidential post.
But it is widely suggested that this year's election will be a two-horse race between the current president and the hardline cleric Raisi.
Who is Rouhani?
With his snow-white beard, he comes across as jovial and scholarly, if not overly charismatic, when speaking in public.
He has presented himself as the candidate of change and social freedoms, attacking his opponents as "extremists" whose "era is over".
His first term did see a groundbreaking 2015 deal with world powers that ended many sanctions and a 13-year standoff over Iran's nuclear programme.
But critics say he over-sold the economic benefits of the deal, and despite taming inflation, his popularity has been dented by continuing stagnation and high unemployment.
And while social restrictions have eased to some degree during his tenure, many journalists and political activists still face arbitrary arrest, and his efforts to release jailed opposition leaders have failed.
A Bill of Rights he announced in late 2016 was roundly dismissed by critics since it failed to impose any changes on the conservative-dominated judiciary and intelligence services.
Still, many young urbanites consider him the best hope for change.
Who is Raisi?
Born into a religious family in the holy city of Mashhad on August 23, 1960, Raisi wears the black turban of a "seyed" whose genealogy is said to lead back to Islam's Prophet Mohammed.
In public, he has an austere charisma, and is surrounded by an entourage with ties to the Islamic regime's most hardline elements.
He has focused his campaign on the poor, brandishing his credentials as the head of the Imam Reza shrine in Mashhad, which is also a powerful and hugely wealthy charitable foundation.
"I represent the workers, the farmers, the impoverished women," he says, vowing to triple cash hand-outs.
It is a message that has fallen on fertile ground at a time when unemployment is at least 12.5 percent and almost everyone is feeling the stagnation of the economy.
He does not oppose the nuclear deal signed with world powers in 2015, which lifted sanctions in exchange for curbs to Iran's atomic programme.
But he says the current government's negotiating efforts were "weak" and called for a much tougher line "in the face of the enemy".
There is little chance Raisi will ease social restrictions or release opposition leaders held under house arrest since the 2009 protest movement, known to conservatives as "the sedition".
"Those who sympathise with the heads of sedition must know that the great nation of Iran will never forgive this great injustice," he said in 2014.