A US man has been charged with murder after opening fire in a crowded bar in Kansas, killing an Indian man and wounding two other men in an attack some witnesses said was racially motivated.

Srinivas Kuchibhotla, 32, died at a hospital while Alok Madasani, 32, and Ian Grillot, 24, were in a stable condition after the attack on Wednesday night in Olathe, Kansas.

Witnesses said the gunman shouted "get out of my country" before he opened fire.

Barman Garret Bohnen told the Kansas City Star newspaper that Kuchibhotla and Madasani stopped at the bar for a drink once or twice a week.

"From what I understand when he [the gunman] was throwing racial slurs at the two gentlemen, Ian stood up for them," Bohnen said.

READ MORE: Mapping hate - The rise of hate groups in the US

Suspect Adam Purinton was taken into custody on Thursday and later charged, authorities said.

Asked if the shooting could be a hate crime, FBI special agent Eric Jackson told a news conference it was too early to determine.

Kuchibhotla was a software engineer at Rockwell Collins, an avionics and information technology company, Rod Larson, his line manager, told the newspaper.

"He was very sharp, a top-of-his-class kind of guy," Larson said.

"His personality was exceptional. He was the kind of employee every manager would want. I couldn't say anything slightly bad about Srinivas."

'I am shocked'

Sushma Swaraj, India's foreign minister, said on Twitter "I am shocked", adding that she would help the family to bring Kuchibhotla's body back to Hyderabad.

Vikas Swarup, spokesperson for India's foreign ministry, said Kuchibhotla was from Telangana state.

Grillot said in an interview from his hospital bed that when the shooting broke out, he hid until nine shots had been fired and he thought the suspect's gun magazine was empty.

"I got up and proceeded to chase him down, try to subdue him," Grillot said in a video posted on the Kansas City Star's website. "I got behind him and he turned around and fired a round at me."

.@USAndIndia strongly condemns the tragic shooting of two Indians and one American in Kansas.Our deepest sympathies. https://t.co/wGjUv35iIJ — MaryKay Loss Carlson (@USAmbIndia) February 24, 2017

Grillot said the bullet went through his hand and into his chest, just missing a major artery.

"It's not about where he [the victim] was from or his ethnicity," Grillot said. "We're all humans, so I just did what was right to do."

US Senator Jerry Moran of Kansas posted a statement on Facebook about the shooting, expressing concern for the safety of other immigrants.

"I strongly condemn violence of any kind, especially if it is motivated by prejudice and xenophobia," Moran said.

Fund-raising drive

A GoFundMe page has been set up to collect money to fly Kuchibhotla's body to India.

The page has crossed its original $150,000 goal, raising nearly $200,000 in eight hours.

The US embassy in New Delhi condemned the shooting.

"The United States is a nation of immigrants and welcomes people from across the world to visit, work, study, and live," MaryKay Carlson, US charge d'affaires, said in a statement.

READ MORE: US anti-fascists - 'We can make racists afraid again'

"US authorities will investigate thoroughly and prosecute the case, though we recognise that justice is small consolation to families in grief."

Hate crimes against Muslims in the US shot up 67 percent in 2015 to their highest levels since the aftermath of the September 11, 2001 attacks, according to FBI statistics released in 2016.

Overall, 57 percent of the 5,850 reported incidents were motivated by race or ethnicity, while 20 percent were related to religion.