President Asif Ali Zardari, the widower of Sharif's former arch-rival and two-time former premier Benazir Bhutto, administered the oath of office to Sharif at the presidential palace in Islamabad.
Sharif crowned a spectacular political comeback last month when his party, the Pakistan Muslim League-Nawaz, won a landslide victory in parliamentary elections.
The May 11 polls marked the first time that an elected government had served its full term in Pakistan's rocky 66-year history.
Earlier Wednesday the National Assembly formally elected Sharif as prime minister. He won 244 of the 342 lawmakers' votes.
In his first speech to the new parliament Sharif, a wealthy steel magnate from Pakistan's largest province, Punjab, invited all parties to form a common agenda to get the country out of crisis.
"I accept the challenge to solve all the problems of the country," he said in address to parliament.
He said Pakistan's 180 million people had "proven that they believe in democracy." Past military dictatorships had ruined the country, he added.
Sharif was prime minister from 1990 to 1993 and again from 1997 to 1999, when then-military chief General Pervez Musharraf overthrew him and forced him into exile. He spent almost eight years in exile in Saudi Arabia before returning to Pakistan late in 2007 to contest the 2008 elections.
Sharif has long advocated dialogue with the Taliban and has been an ardent critic of the U.S. campaign of deadly attacks by unmanned drones in Pakistan's remote western borderlands, in which hundreds of people including women and children have been killed.
There have been 273 drone strikes in Pakistan since 2005, killing 2,514 people, according to the South Asia Terrorism Portal website.
Sharif used his first speech to the new parliament to call for an end to the drone strikes.
"We respect the sovereignty of others. Our sovereignty should also be respected," he said.
The new prime minister, who made major infrastructure projects a signature of his previous terms, also promised to build a railway from Pakistan's northern border with China to a new super port on the south coast at Gwadar.
He is the first prime minister in Pakistan to hold the post for a third term.
Celebrity Breakups and divorces of 2014 [PHOTOS]