ISTANBUL — A huge opposition political rally in the predominantly Kurdish city of Diyarbakir on Friday ended with smoke, panic and defiance as two explosions killed two people and wounded more than 100 others, a senior government minister said.

The blasts came as Selahattin Demirtas, the leader of a pro-Kurdish group, the People’s Democratic Party, prepared to address hundreds of thousands of supporters at the rally, one of the final campaign events before Sunday’s national election.

Officials initially said a faulty transformer had caused the explosions, but the energy minister, Taner Yildiz, told CNN Turk that the blasts occurred away from electrical equipment, ruling out a malfunction. Video of the second explosion, and the ensuing panic, was shared online by Hayat TV, a broadcaster that came under fire from the authorities for covering protests in Istanbul in 2013.

The episode occurred at a particularly tense time in Turkish politics, with just two days left until the country votes in what analysts have described as one of the most consequential elections in its history.