In the wake of two attacks on police officers in as many weeks, leaving a total of eight officers dead, President Barack Obama penned an open letter to law enforcement, committing to support them and fight the notion of pervasive division in the country.

"Any attack on police is an unjustified attack on all of us," Obama wrote, repeating what he told the nation Sunday after three police officers were fatally shot in Baton Rouge. A little more than a week earlier, five officers had been killed by a sniper in Dallas during a protest over the fatal police shootings of two black men in separate cities.

Related: Baton Rouge Police Attack Follows Alton Sterling Shooting, Unrest

"Some are trying to use this moment to divide police and the communities you serve. I reject those efforts, for they do not reflect the reality of our Nation," Obama said in his letter.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The president lauded the work that officers do and said they shouldn't be solely responsible for alleviating racial tensions in the country.

"As you continue to serve us in this tumultuous hour, we again recognize that we can no longer ask you to solve issues we refuse to address as a society," Obama wrote. "This is a time for us to reaffirm that what makes us special is that we are not only a country, but also a community. That is true whether you are black or white, whether you are rich or poor, whether you are a police officer or someone they protect and serve."

Related: Obama to Dallas Mourners: 'We're Not as Divided as We Seem'

In a statement, the National Fraternal Order of Police said the letter sent an important message because "we want and deserve to change the national dialogue."

"We can and do provide the best quality law enforcement that we can but we cannot be held responsible for the social issues such as poverty, lack of mental health services, unemployment, and abject poverty," the statement said. "Now it's time for politicians and government to assist us in working in the communities we have always worked in to make life better for all Americans."

Law enforcement officials have sharply criticized Obama and some of his policies, including a decision to stem the flow of military-grade equipment to local departments. One prominent voice, William Johnson, executive director the National Association of Police Organizations, has accused Obama of waging a "war on cops."

But Obama warned that politicizing the challenges the country faces with regards to policing and race will only make the problem worse.

Related: How The Racial Divide is Reinforced by Partisanship

"As we bind up our wounds, we must come together to ensure that those who try to divide us do not succeed," Obama wrote. "We are at our best when we recognize our common humanity, set an example for our children of trust and responsibility, and honor the sacrifices of our bravest by coming together to be better."

"We have your backs," Obama concluded.