But the opposition dropped a demand for talks with the government.
Before the opposition rally began, police fired tear gas at protesters who chanted slogans against President Uhuru Kenyatta and clambered over statues in Nairobi's streets. They also shot gas canisters at youths who hurled stones at them at the park venue of the gathering.
But the rally passed off calmly, after many Kenyans had feared it would stoke tensions in a nation battling an upsurge in political violence. In the latest assaults on Saturday, gunmen killed at least 29 people at two locations on the coast.
Somali Islamist group al Shabaab said it carried out those and other attacks, vowing to drive Kenyan and other African Union forces out of Somalia. The government has blamed local politicians instead, drawing angry denials from the opposition.
"Time for talks is over," opposition leader and veteran politician Raila Odinga told his supporters, speaking on the day he had said was the deadline for dialogue.
Fellow opposition politician, Stephen Kalonzo Musyoka, told the crowd: "We cannot speak with deaf people."
Odinga had promised mass rallies to drive home his message. Several thousand turned up at the rally but that was fewer than had gathered at the same park on May 31 to welcome the veteran politician home from three months abroad.
Religious leaders had called for calm and some told their congregations to stay away, fearing the event could fuel the kind of political violence that has haunted Kenya in recent years.
The government said anyone heeding Odinga's call to take a day off work would be disciplined.
In a list of demands issued at the rally, the opposition called on the government to take "immediate steps to withdraw our gallant soldiers from Somalia", deal with "runaway insecurity", halt price rises and address other grievances.
Government officials had dismissed the opposition's demand for talks, saying the place for discussion was parliament. They have also repeatedly said Kenya will not withdraw from Somalia.
"This country is not well and this government hasn't delivered a single thing from their manifesto," said Mohamed Hassan, 30, at the rally. "Raila Odinga wants people to get jobs and (a) poor man to get a good home."
Officials and police had until recently routinely blamed the Somali group al Shabaab for strikes on Kenyan soil, including a raid on a Nairobi shopping mall last year that killed 67 people.
But after attacks on the coast last month that killed about 65 people, the president dismissed al Shabaab's claim and instead pointed the finger at local political networks. Deputy President William Ruto made similar remarks on Sunday after the weekend attacks.
The government statements have left Kenyans confused about who is behind the militant strikes, several of them in Lamu County which borders Somalia, and worried that political squabbling will hamper a security campaign to stop them.
"More time and resources have been spent on blaming the killings on the opposition CORD alliance and its ongoing political rallies than in restoring security in Lamu County and elsewhere where similar threats abound," wrote the Daily Nation.
Diplomats accused both sides of playing with fire in a nation where politics and ethnic loyalties usually run in tandem. "Kenya is a tinderbox," said one Western diplomat.
A contested election at the end of 2007 sparked weeks of ethnic bloodletting that killed about 1,200 people.
Militant attacks since June have hit areas on the coast with long running disputes over land ownership, fuelled by ethnic rivalries among traditional communities, Kenyatta's Kikuyu group and others.
Some police officials have said that suggests local rivalries might be to blame.
But analysts say it is too soon to rule out a role for al Shabaab, which may have changed tack, perhaps using local knowledge or sympathisers, to target a region where deep ethnic divisions could easily be re-opened.