The arrests came the same day the election campaign took a deadly turn. More than 130 people, including a candidate from another party, were killed in two militant attacks elsewhere in Pakistan.
The Sharifs were convicted in absentia last week and sentenced to lengthy prison terms in connection with their ownership of expensive properties in London, a case they say was manufactured by their political foes and the country’s powerful military.
Though the Sharifs cannot run in the July 25 election, analysts said they felt compelled to return from London, where they had been for many weeks, to give a lift to their party in what has become a highly charged campaign.
Mr. Sharif, a three-time prime minister who has been shadowed by corruption accusations throughout his career, is also concerned about cementing a legacy as a champion of civilian governance and opponent of the military’s overarching role, they said.
High drama surrounded the arrests as the authorities blocked roads, shut down mobile and internet service and deployed thousands of officers to thwart supporters of the Sharifs from reaching the airport. The police arrested at least 600 workers of Mr. Sharif’s political party, Pakistan Muslim League-Nawaz, or PML-N, on security-related charges in the past several days.
Officials from the National Accountability Court, the anti-corruption watchdog, placed the Sharifs under arrest as they arrived on an Etihad Airways commercial flight shortly before 9 p.m. They were transferred to Adiala Prison on the outskirts of Rawalpindi.
“Pakistan is at a decisive turning point,” Mr. Sharif said in a recorded video message to supporters that cast doubt on the credibility of the coming election. Photos of Mr. Sharif saying goodbye in London to his ill wife, Kulsoom Nawaz Sharif, went viral in the country’s social media.
The show of force by the government in Punjab Province, which includes Lahore, was effective in turning back thousands of the Sharifs’ supporters from the airport, but it also appeared to have engendered a backlash.
Talat Hussain, a veteran journalist and popular talk show host, said he had never seen such “palpable anger against the establishment” in Lahore. “People have come out in the thousands to endorse Nawaz Sharif,” Mr. Hussain said by phone from Lahore. “There is anger against suppression. Against manipulation. Against blackout.”
Police officers and members of a paramilitary force known as the Rangers clashed with protesters in several cities in Punjab Province, the country’s most populous and a stronghold of Mr. Sharif’s party, as rallies moved toward Lahore. Entry points to Lahore, the former prime minister’s hometown, were blocked with shipping containers.
Human rights activists condemned the provincial government’s actions. “It’s the sort of crude repression that recalls dark periods of Pakistani history under military rule,” said Omar Waraich, deputy South Asia director for Amnesty International.
Ahmed Waqas Riaz, Punjab’s interim information minister, said in an interview that the government did not use excessive force. “Force was only used at a few places where it was necessary to maintain law and order,” he said. “Airport and other sensitive installations had to be kept safe from any untoward situation.”
Mr. Riaz said crowds of protesters in Lahore reached a little over 10,000 people.
Marriyum Aurangzeb, a spokeswoman for PML-N, said in an interview that supporters numbered in the hundreds of thousands. “There would have been no media blackout by the authorities if only a few thousand people had shown up,” Ms. Aurangzeb said. “There were people as far as one could see on the roads.”
The corruption investigation against the Sharifs arose from the so-called Panama Papers leak, which unearthed details of expensive properties the family owned in London. Mr. Sharif has denied any wrongdoing, but he could not adequately explain how he could afford the properties and he could not provide a money trail.
The same allegations led the Supreme Court to remove Mr. Sharif as prime minister last year and later bar him from seeking office again.
Mr. Sharif has accused the military of pressuring the judiciary to act against him, and of interfering in the current campaign by intimidating and arresting party members. He and the leaders of other political parties also accuse the military of lending support to Imran Khan, who leads the Pakistan Tehreek-e-Insaf party, or P.T.I.
The military denies the accusations.
“These elections will be intensely competitive, and despite having the kitchen sink thrown at it, the PML-N could be positioned to lead a fragile coalition government,” said Arif Rafiq, a political analyst and nonresident fellow at the Middle East Institute. “But if the election outcome tilts heavily in favor of P.T.I., the results will be challenged by other major parties.”
He added, “What is more or less certain is that Pakistan is entering another period of prolonged political instability.”
Mr. Rafiq suggested the Sharifs and the military had set a course that led inevitably to Friday’s showdown.
“The arrest of Nawaz is a scenario many in his party and the army likely wanted to avoid, but neither Nawaz’s camp nor the army were able to find compromise,” he said. “The army appears to have been keen on securing Nawaz’s conviction before the elections, to damage his party. Nawaz had no choice but to return, as he is only able to appeal after surrendering to authorities.”
A spike in violence has added to the sense of political turmoil.
Militants, breaking a lull in attacks over the past several months, have targeted candidates in a series of recent assaults, including two on Friday. A candidate and at least 127 others were killed in a suicide bombing at a campaign event in southwestern Pakistan. The Islamic State claimed responsibility for the attack. In the northwest, a candidate escaped injury in an attack on his convoy that killed four people.
New York Times