The Muslim-majority state of Pakistan occupies an area that was home to some of the earliest human settlements.
The modern state was born out of the partition of the Indian sub-continent in 1947, and has faced both domestic political upheavals and regional confrontations.
Created to meet the demands of Indian Muslims for their own homeland, Pakistan was originally made up of two parts.
The east wing - present-day Bangladesh - is on the Bay of Bengal bordering India and Burma. The west wing - present-day Pakistan - stretches from the Himalayas down to the Arabian Sea.
The break-up of the two wings came in 1971 when the Bengali-speaking east wing seceded with help from India.
The disputed northern territory of Kashmir has been the flashpoint for two of the three India-Pakistan wars - those of 1947-8 and 1965. There was a further brief but bitter armed conflict after a major infiltration of Indian-administered Kashmir by Islamic militants in 1999.
At a glance
- Politics: Polarised parties, the influence of political Islam, and frequent military interventions have left Pakistan's democracy weak. Only in 2013 did one elected government hand over power to another at elections
- Economy: The precarious security situation and low fixed investment leave Pakistan's economy fragile, despite a robust private sector
- International: India and Afghanistan accuse Pakistan of protecting Islamist insurgents, which makes for tense and sometimes explosive relations. Pakistan gets on better with China and, like India and Bangladesh, is one of the most important contributors to UN peacekeeping missions
Country profiles compiled by BBC Monitoring
Civilian politics in Pakistan in the last few decades has been tarnished by corruption, inefficiency and confrontations between various institutions. Alternating periods of civilian and military rule have not helped to entrench any stability.
Pakistan came under military rule again in October 1999. Coup leader General Pervez Musharraf pledged to revive the country's fortunes, but failed to boost the economy or lessen polarisation between Islamist militancy and the modernising secular wing of politics.
Under growing pressure to reintroduce democratic rule, Mr Musharraf relinquished his army post in November 2007, but his supporters were defeated at parliamentary elections in February 2008 by the Pakistan People's Party and former prime minister Nawaz Sharif's Muslim League.
The two parties formed a coalition government that forced Mr Musharraf out of office, but it soon fell apart.
The People's Party governed with smaller parties until elections in 2013 brought the Muslim League back to power, in the first transition from one elected government to another at elections in the country's history.Regional tensions and terror
Pakistan's place on the world stage shifted after the 11 September 2001 attacks in the US. It dropped its support for the Taliban regime in Afghanistan, and found itself on the frontline in the fight against terrorism, becoming an uneasy ally of the United States.
However, Pakistani forces have struggled to maintain control over the restive tribal regions along the Afghan border, where Taliban-linked militants are firmly entrenched. These Sunni extremists have more recently expanded attacks to target minority groups elsewhere in the country, in particular Shia Muslims and Christians.
Since 2009, the government has been waging an on-and-off military campaign to flush the militants out of the tribal areas.
It repeatedly denied US and Afghan allegations that senior al-Qaeda and Taliban leaders were present in the border areas, or that its ISI military intelligence service had links to these armed groups. So the death in April 2011 of al-Qaeda chief Osama Bin-Laden in a US raid on Abbottabad, a city in the heart of Pakistan's military establishment, stretched relations with the US to breaking point.
Tensions with India over Kashmir have resurfaced regularly ever since the partition of the sub-continent, and the two nuclear-armed powers have on numerous occasions been on the brink of renewed conflict.