The attempt, which officials blamed on soldiers loyal to the previous government of Omar al-Bashir, laid bare divisions between military and civilian groups sharing power during a transition that is meant to run to 2023 and lead to elections.
Many protesters came from outside Khartoum by train from the cities of Atbara and Madani. A crowd of thousands celebrated the arrival of the Madani train, climbing on top, waving national flags and chanting "the army is Sudan's army, not Burhan's army" - a reference to General Abdel Fattah al-Burhan, the leader of Sudan's military and its ruling sovereign council. Civilian officials greeted the protesters.
But security forces later fired volleys of tear gas to break up the gathering, a Reuters reporter said.
After last week's coup attempt, civilian officials accused military leaders of overstepping their bounds, while generals criticized civilian management of the economy and political process and said their forces were neglected and disrespected.
The military removed Bashir in April 2019 after months of protests triggered by an economic crisis.
It then signed a power-sharing deal with the civilian Forces of Freedom and Change coalition.
The FFC supported Thursday's demonstrations, which converged on the central Khartoum headquarters of a task force working to dismantle the Bashir administration.