President Obama has posted an open letter to American law enforcement officers after two recent attacks that left eight police officers dead in Dallas and Baton Rouge.

The letter was posted on the Facebook page of the Fraternal Order of Police and shared by the White House on social media. 

The president thanked the law enforcement community for its "courageous service" and declared that, "We have your backs."

He lamented attempts to divide police officers and communities.

"I reject those efforts, for they do not reflect the reality of our nation."

The president shared personal stories of some of the slain officers, saying that "our Nation grieves alongside you."

Obama said any attack on a police officer is an "unjustified attack on all of us."

He credited officers for serving in a "tumultuous" time and emphasized that police officers cannot be asked to "solve issues we refuse to address as a society."

"We should give you the resources you need to do your job, including our full-throated support," he wrote, asking, "What is more patriotic?" than police officers protecting anti-police protesters.

"We will get through this time together," the president wrote. 

The letter comes after speakers at the Republican National Convention - including Rudy Giuliani and Sheriff David Clarke - harshly criticized Obama for what they see as a lack of support for police officers. 

Sheriff Clarke: 'Let's Make Something Very Clear... Blue Lives Matter'

Giuliani: When Police 'Come to Save Your Life, They Don't Ask if You're Black or White'

'There's No Reasoning With You': Kelly Challenges Ex-Black Panther Leader