Former President Barack Obama issued a rare and lengthy public statement calling for action to reduce gun violence after two mass shootings in El Paso, Texas, and Dayton, Ohio, killed a combined 31 people over the weekend.

"No other developed nation tolerates the level of gun violence that we do. Every time this happens, we're told that tougher gun laws won't stop all murders ... but the evidence shows that we can stop some killings," Obama wrote.

The former president also issued what appeared to be a thinly veiled rebuke of President Donald Trump's racist and racially inflammatory language against immigrants and nonwhite Democratic members of Congress.

"We should soundly reject language coming out of the mouths of any of our leaders that feeds a climate of fear and hatred," Obama wrote.

Visit Business Insider's homepage for more stories.

Former President Barack Obama issued a rare and lengthy public statement calling for action to reduce gun violence after two mass shootings in El Paso, Texas, and Dayton, Ohio, killed a combined 31 people over the weekend.

"No other developed nation tolerates the level of gun violence that we do. Every time this happens, we're told that tougher gun laws won't stop all murders ... but the evidence shows that we can stop some killings," Obama wrote. "They can save some families from heartbreak. We are not helpless here. And until all of us stand up and insist on holding public officials accountable for changing our gun laws, these tragedies will keep happening."

On Saturday, a gunman killed 22 people and injured 24 more after opening fire inside an El Paso Walmart. In the early hours of Sunday morning, a shooter killed 9 people and injured 27 more in Dayton's Oregon District.

Obama further called out the troubling white-nationalist and white-supremacist sentiment in a manifesto believed to have been published by the El Paso shooting suspect on 8chan shortly before the attack, in which he talked of needing to end a "Hispanic invasion" of Texas.

"Like the followers of ISIS and other foreign terrorist organizations, these individuals may act alone, but they've been radicalized by white nationalist websites. That means that both law enforcement agencies and internet platforms need to come up with better strategies to reduce the influence of these hate groups," he said.

Read more: The Trump campaign's Facebook ads promoting 'invasion' rhetoric are similar to what the El Paso shooting suspect wrote

The former president also issued what appeared to be a thinly veiled rebuke of President Donald Trump's racist and racially inflammatory language against immigrants and nonwhite Democratic members of Congress.

In mid-July, Trump tweeted that four progressive congresswomen of color should "go back and fix the totally broken and crime-infested places from which they came," despite three of the four congresswomen being born in the US.

And on July 27, Trump fired off a series of tweets slamming the city of Baltimore and one of its congress members, Rep. Elijah Cummings, over its living conditions.

Trump described the district — which is majority African American — as a "disgusting, rat and rodent-infested mess," saying of Cummings, "if he spent more time in Baltimore, maybe he could help clean up this very dangerous & filthy place," further calling it "the worst run and most dangerous anywhere in the United States" and saying that "no human being would want to live there."

Obama wrote, "we should soundly reject language coming out of the mouths of any of our leaders that feeds a climate of fear and hatred or normalizes racist sentiments, leaders who demonize those who don't look like us, or suggest that other people, including immigrants, threaten our way of life, or refer to other people as sub-human, or imply that America belongs to one certain type of people."