A man who police say fatally stabbed two people who tried to stop him from yelling anti-Muslim slurs on a Portland light-railway train spent time in prison for robbery and kidnapping charges years ago, according to court records and a lawyer.

Jeremy Joseph Christian, 35, was being held in the Multnomah County Jail on Saturday on suspicion of aggravated murder, attempted murder, intimidation and being a felon in possession of a weapon.

Two people died on Friday and another was hurt in the stabbing after police say Christian yelled racial slurs at two young women, one of whom was wearing a hijab. The assailant on the train was ranting on many topics, using "hate speech or biased language," according to a statement from police.

After fleeing the scene, he was arrested late on Friday. He will make a first court appearance on Monday.

Friday was the beginning of Ramadan, the holiest time of the year for Muslims, and the attack prompted soul-searching in Portland, a city that prides itself on its tolerance and liberal views. A memorial of flowers and signs quickly grew at the scene by a transit station.

"There is too much hatred in our world right now, and far too much violence. Too much of it has arrived here in Portland," Mayor Ted Wheeler said in Facebook post.

Dyjuana Hudson, a mother of one of the girls, told The Oregonian newspaper that the man began a racial tirade as soon as he spotted the girls. Her daughter is African-American and was with a friend who was wearing a hijab, she said.

"He was saying that Muslims should die," Hudson said. "That they've been killing Christians for years."

Christian was a known local white supremacist, according to local media.

Autopsies on the victims were being done on Saturday. Their names have not been made public.

Police say the victims were trying to stop Christian from confronting the girls.

"In the midst of his ranting and raving, some people approached him and appeared to try to intervene with his behavior and some of the people that he was yelling at," police sergeant Pete Simpson told The Oregonian. "They were attacked viciously."

A criminal past

Christian has had several encounters with the law.

In 2002, Christian, then 20, was arrested and charged with first-degree robbery and second-degree kidnapping after he rode to a convenience store on his bike and held up employees there with a gun, according to court records and his court-appointed defence lawyer at the time, Matthew Kaplan.

When police caught up with him, Christian aimed the gun at himself in a suicide attempt before he was shot and injured by police, Kaplan said.

Christian was sentenced to more than seven years in prison after striking a plea deal that eliminated coercion and weapons charges.

OPINION: How Muslim Ban incites vigilante Islamophobic violence

At the time, Kaplan suspected the onset of mental illness to explain his actions.

"It was so random, the event in his life. It made no sense that he did this at his age. He had no background like this, no history of violence and then he goes and gets a gun and robs a store," Kaplan told The Associated Press in a phone interview.

Christian had another brush with the law in 2010, when he was arrested on charges of being a felon in possession of a firearm and theft. Those charges were dismissed, according to court records, which do not explain why.