Barack Obama told an interfaith ceremony that everyone had been touched by the attack on their beloved city.
The president spoke as it emerged investigators had found clear video images of two potential suspects carrying black bags.
Two bombs were detonated near the finish line on Monday, killing three people and injuring more than 180.
There were several standing ovations as President Barack Obama spoke on Thursday at the Cathedral of the Holy Cross, the main Roman Catholic cathedral in Boston.
Before his visit, the president declared a state of emergency in Massachusetts, which would allow the state to access federal funding to deal with the aftermath of the attacks.
Barack Obama appeared in sombre mood as he joined city leaders, residents and victims at the prayer service.
He told the congregation: “The spirit of this city is undaunted; the spirit of this country shall remain undimmed.
“Everyone of us has been touched by this attack on your beloved city. Everyone of us stands with you. Because after all it’s our beloved city too.”
“They sought to intimidate us, to terrorize us,” he said.
Then added: “It should be pretty clear by now that they picked the wrong city to do it.”
Barack Obama was applauded as he warned the perpetrators of the attacks they would be brought to justice.
“We will find you,” he said.
“We will hold you accountable.”
Hundreds of people stood outside the cathedral during the service, while police at the bomb site listened to the president’s speech on the radios in their patrol cars.
Former Republican presidential challenger Mitt Romney also attended the prayer ceremony.
Barack Obama is later expected to meet emergency workers and the families of victims.
On Thursday Homeland Security Secretary Janet Napolitano said the FBI wanted to speak to two men, but did not say they were suspects.
“There is some video that has raised the question of those that the FBI would like to speak with,” Janet Napolitano said.
“I wouldn’t characterize them as suspects under the technical term, but we do need the public’s help in locating these individuals.”
She did not give details of what was seen on the tape.
Janet Napolitano would not say whether the attacks were suspected to be the work of a domestic or foreign group, but said the investigation was continuing “apace”.
She added that security had been ramped up at airports and transport hubs.
The FBI has denied a flurry of reports on Wednesday that a suspect had been arrested.
Investigators are going through thousands of images taken around the time of the attacks from security cameras, the media and people at the scene.
Officials have not said if they would publicly release more details of the case.
Correspondents say authorities are cautious about publicizing the relevant images, after the release of pictures relating to a 1996 bombing at the Atlanta Olympics led to the arrest of an innocent security guard, Richard Jewell.
A circuit board and battery pack – parts of a triggering mechanism – has been recovered.
The lid of a pressure cooker, apparently blown off during the explosion, was found on the roof of a nearby building.
Officials say the bombs consisted of explosives in pressure cookers, one with shards of metal and ball bearings, the other with nails.
Nobody has claimed responsibility for the attack.
The twin blasts killed three people: Martin Richard, 8, Krystle Campbell, 29, and Lu Lingzi, a postgraduate student from China.
Dozens remain in hospital following the bombs, many of them seriously injured.
It is reported that 10 victims have had limbs amputated. Nails and ball bearings were said to be embedded in their flesh.
At least 14 bombing victims, including three children, remain in hospital in a critical condition.
At least 158 people have died in Spain's worst flooding disaster in generations. On October…
Google has been fined two undecillion (a two followed by 36 zeroes) roubles by a…
Embarking on a home remodel is an exciting journey, promising enhanced comfort, increased property value,…
The US presidential candidates continued to campaign across key swing states on October 20. Footage…
Elon Musk has said he will give away $1 million a day to a registered…
India and Canada have decided to expel their top envoys along with other diplomats as…