WARSAW (Reuters) - President Barack Obama pledged on Saturday to seek ways to calm racial tensions and reduce divisions between police and minorities during his final months in office, but he warned that easy access to guns nationwide exacerbated the problem.

Slideshow ( 6 images )

Obama spoke at the end of a week in which five policemen were killed by a sniper in Dallas and two black men were killed by police in Minnesota and Louisiana. He said he would bring together civil rights and law enforcement leaders for talks at the White House next week after returning from a trip to Europe.

Obama, the first black U.S. president, has spoken out on racial issues throughout his time in the White House. He has also tried but failed to reform American gun laws, stymied by Republicans in Congress who have opposed any measures that they seen as impinging on the Constitutional right to bear arms, despite a series of mass shootings in recent years.

Obama said the Dallas police force reduced murder rates and community complaints by taking the issue of race and police conduct seriously, and said he hoped that would inspire “constructive actions” in the coming weeks.

“That’s the spirit that we all need to embrace. That’s the spirit that I want to build on,” he said during a press conference in Poland.

But the divisive issue of gun control could not be separated from the tension between police and local citizens, he said.

Obama noted that Dallas police on Thursday had to protect themselves and citizens from sniper fire while deciphering who had guns among those taking part in a protest decrying police shootings of black men.

The presence of a gun in the car where Philando Castile, 32, was killed by police in Minnesota on Wednesday contributed to that event, he said.

“In Minneapolis, we don’t know yet what happened, but we do know that there was a gun in the car that apparently was licensed, but it caused, in some fashion, those tragic events,” Obama told reporters.

“We can’t just ignore that and pretend that that’s somehow political ... it is a contributing factor – not the sole factor – but a contributing factor to the broader tensions that arise between police and the communities where they serve.”

Obama is very unlikely to succeed in reviving major gun control reform before he leaves office in January.

Lawmakers in Congress have fought over three rival gun measures since the June 12 mass shootings at a gay nightclub in Orlando. Democrats promised to put pressure on Republicans next week to win votes for measures to expand background checks and allow the Justice Department to block gun sales to people on government watch lists.

Obama said on Saturday he hoped his legacy on the issue of race would be one of urging Americans to listen to each other and understand the country’s difficult relationship with race.

“The legacy of slavery and Jim Crow and discrimination didn’t suddenly vanish with the passage of the Civil Rights Act or the Voting Rights Act or the election of Barack Obama,” he said.

He said he hoped his words as president had conveyed “that things have gotten better, substantially better, but that we’ve still got a lot more work to do.”