By Abdi Sheikh

MOGADISHU (Reuters) - Members of Somalia's new parliament to be elected this year must join a political party within two years or step down as part of efforts to shift the Horn of Africa nation away from clan-based politics, a forum of regional and national leaders said.

Somalia is slowly rebuilding after more than two decades of conflict and chaos fueled largely by clan rivalries. It holds an election in September for the new parliament, whose lawmakers will in turn choose a president in October.

Somali authorities and international sponsors had to scrap a plan for each person to get a vote, largely due to security challenges as the Western-backed government is still battling an Islamist insurgency.

Instead, about 14,000 people from federal states will choose the 275 members of the lower house of parliament. While that represents a fraction of Somalia's 11 million people, it is more than the 135 elders who picked the 2012 parliament.

"The leaders of the National Leadership Forum agreed to promote the establishment and registration of political parties within two years, starting from the date when the 10th parliament is elected," the forum said after a week-long meeting.

The forum, which includes President Hassan Sheikh Mohamud, senior cabinet members and regional leaders, said political parties would have to register and all members of parliament would have to join one group by Oct. 20, 2018. Any lawmaker who failed to join a party would lose his or her seat.

Although some lawmakers group together, there is no formal party structure or registration system now.

This year's election process will start on Sept. 24 with the parliamentary vote and culminate with the choosing of a president on Oct. 30. Mohamud is seeking another term.

Diplomats have pushed Somalia to hold elections on time to avoid a major extension of parliament's term. The vote has already slipped from August, but diplomats had said a few weeks' delay was expected given the scale of the reconstruction effort.

The term of the existing parliament formally ends on Aug. 20 and the president's term expires on Sept. 9. The leadership forum said office holders would stay in post until new leaders are in place.

(Writing by George Obulutsa; Editing by Edmund Blair and Janet Lawrence)