Tanzania's ruling party narrowly won a key parliamentary by-election after a tight race marked by low voter turn-out, pointing to a decline in popularity of the party even in regions where it enjoyed strong support.

Less than a third of registered voters cast their ballots in the poll in Igunga constituency in the northwest of the country, where the ruling Chama Cha Mapinduzi (CCM) party faced a stiff challenge from the opposition CHADEMA party.

Dalaly Peter Kafumu of CCM was declared winner after he got 50.46 percent of the vote while Joseph Kashindye of CHADEMA came in second with 44.32 percent of the vote, the Igunga constituency's returning officer, Protace Magayane, told Reuters by phone on Wednesday.

A total of 53,672 voters out of 171,019 registered voters in Igunga turned out to vote in the parliamentary by-election.

One analyst said the result of the election was yet another signal of a gradual end to the one-party mentality in Tanzania.

CCM has ruled east Africa's second-largest economy since independence in 1961, but saw its popularity plunge in the last general election in 2010 despite cruising to victory.

The results of the election demonstrate a maturity of democracy in Tanzania. CHADEMA fielded a candidate for the first time in the Igunga constituency and was highly competitive because of its emergence in the national spotlight, Palamagamba Kabudi, dean of the University of Dar es Salaam's law school, told Reuters.

The low voter turnout can be explained by the fact that many people were scared to go out and vote due to the manner in which the campaigns were conducted. The people of Igunga were just spectators in this election.

During campaigning, which followed the resignation of Rostam Aziz in July after being accused of graft by CCM's national executive committee, national politicians from both sides trooped to the far-flung area, demonstrating the importance of the vote.

Local media showed politicians from Dar es Salaam using helicopters to campaign in Igunga.