ISLAMABAD, Pakistan—Former Prime Minister Nawaz Sharif’s overwhelming victory in parliamentary elections this weekend returns to power a seasoned politician who historically has had rocky ties with Pakistan’s powerful military and is viewed by many as soft on militants and extremist groups.

The expected showdown between Sharif, 63, and former cricket star Imran Khan never really materialized, as Sharif swept the elections and put himself in a position to become prime minister for an unprecedented third time.

With much of the vote counted, unofficial results had Sharif winning at least 46% of the seats in the National Assembly, according to Pakistani media projections. It was still unclear whether the final tally would give him an outright majority of seats, but his clear margin of victory meant he would easily be able to bring into his fold the handful of independent lawmakers and winning candidates from the country’s religious parties to form a government.

Trailing far behind Sharif’s Pakistan Muslim League-N Party were Khan’s Movement for Justice Party with a projected 11% of parliament seats, and President Asif Ali Zardari’s outgoing Pakistan People’s Party, with nearly 12%. Official results were not expected to be released until later in the week.

A former steel baron and one of Pakistan’s wealthiest men, Sharif served as prime minister from 1990 to 1993 and again from 1997 to 1999, until the army chief at the time, Gen. Pervez Musharraf, ousted him from power. Sharif lived in exile in Saudi Arabia until 2007, when he returned to Pakistan. His party won the Punjab provincial assembly elections in 2008 and garnered enough seats in parliament to become the main opposition rival to Zardari’s PPP.

He has always had a difficult relationship with Pakistan’s military, which has run the country for more than half of its 65-year history and still holds sway over major foreign policy matters, such as Islamabad’s ties with the U.S., Afghanistan and India. Many in Pakistan criticize him for what they say is his dangerous tolerance of extremist groups, including Sunni sectarian outfits that continue to wage a deadly campaign of violence against the country’s Shia minority.

He also has espoused dialogue with the Pakistani Taliban, the country’s homegrown insurgency, a position that is likely to put him at odds with the military, which sees the Taliban as one of Pakistan’s most pressing threats.

“He is softer on militants, and that will bring him in some divergence with the military,” said Hasan Askari Rizvi, a Lahore-based political analyst. “So unless he revises his approach, he’s going to land in trouble.”

During the campaign, Sharif also promised to review Pakistan’s relations with the U.S. and perhaps pull back on the country’s collaboration with America in battling Islamist militants, a prospect that may unsettle officials in Washington. Although U.S.-Pakistan relations remain the purview of the military and its head, army chief Gen. Ashfaq Kayani, Rizvi expects Sharif’s ties with the U.S. to begin with “a period of uncertainty and confusion.”

Khan, 60, was regarded by most analysts to be Sharif’s most formidable challenger. The charismatic former cricketer was able to amass widespread support from middle class voters in Pakistan’s larger cities, particularly younger Pakistanis. But he was unable to garner much support in rural Punjab, where Sharif has longstanding ties with clan-based societies, or within the province’s business community, which has always had a good relationship with the former prime minister.

“I voted for the first time, and I voted for PML-N,” said Manan Butt, 20, a small-business owner from Lahore. “Businesses always prosper when PML-N is in power.”

Widespread disappointment with Zardari’s PPP, which ruled Pakistan for the last five years, bolstered the campaigns of both Sharif and Khan and led to the party’s dismal performance Saturday. Sharif’s candidates defeated several top PPP leaders, including former Information Minister Qamar Zaman Kaira, former Prime Minister Raja Pervaiz Ashraf, and ex-Defense Minister Chaudhry Ahmad Mukhtar.

Voters criticized Zardari’s party’s failure to remedy crippling power outages, rev up a stagnant economy, and reverse the tide of terror attacks that have claimed the lives of thousands in recent years.