* President gives final State of the Union address
* Criticizes anti-Muslim rhetoric
* Seeks to cement his legacy
* Calls for "fix" to U.S. politics (Recasts, adds quotes, reaction)
By Jeff Mason and Roberta Rampton
WASHINGTON, Jan 12 (Reuters) - President Barack Obama took aim on Tuesday at Republican presidential front-runner Donald Trump and accused critics of playing into the hands of Islamic State in a speech meant to cement his legacy and set a positive tone for his final year in office.
Obama, delivering his last annual State of the Union speech to Congress as president, called for leaders to "fix" U.S. politics and criticized candidates such as Trump for using anti-Muslim rhetoric that betrayed American values.
"When politicians insult Muslims ... that doesn't make us safer," he said, drawing applause from the crowd in the House of Representatives chamber. "It's just wrong. It diminishes us in the eyes of the world. It makes it harder to achieve our goals."
Trump, whom Obama did not mention by name in his speech, is leading the Republican field ahead of the Nov. 8 election to pick the next president.
The billionaire businessman, citing national security concerns, has called for a temporary ban on Muslims entering the United States and a wall on the U.S. border with Mexico to stop the flow of illegal immigrants, ideas the White House strongly opposes.
Obama sought to contrast his more optimistic view of America's future with those of the Republican candidates trying to replace him.
He said it was "fiction" to describe the country as being in economic decline. While acknowledging that al Qaeda and Islamic State posed a direct threat to Americans, he said comparing the effort to defeat the militants who control swaths of Iraq and Syria to World War Three gave the group just what it wanted.
"Masses of fighters on the back of pickup trucks, twisted souls plotting in apartments or garages: they pose an enormous danger to civilians; they have to be stopped. But they do not threaten our national existence," Obama said.
Republicans say the president's strategy to defeat Islamic State is flawed and insufficient.
"His policies aren't working. He didn't have an answer for how to defeat ISIS," Republican House of Representatives Speaker Paul Ryan said in a statement after the speech, using an acronym for Islamic State.
Obama's address to lawmakers, Cabinet members and Supreme Court justices was one of his last remaining chances to capture the attention of millions of Americans before the November election. The next president will take office in January 2017.
Trump, in a posting on Twitter, called the speech "boring" and lacking in substance. "New leadership fast!"
But South Carolina Governor Nikki Haley, who delivered the Republican response to Obama's address, took her own jab at Trump and other less moderate candidates in her party.
"During anxious times, it can be tempting to follow the siren call of the angriest voices. We must resist that temptation," said Haley, the daughter of Indian immigrants. "No one who is willing to work hard, abide by our laws, and love our traditions should ever feel unwelcome in this country," she said.
Obama's address came as 10 sailors aboard two U.S. Navy boats were taken into Iranian custody. Iran told the United States the crew members would be "promptly" returned, U.S. officials said. The event gave Republicans further fodder to criticize Obama's nuclear deal with Tehran.
Obama did not address the issue in his speech. The White House expects the situation to be resolved quickly.
Obama, who is constitutionally barred from a third term, stuck to themes he hopes will define his legacy, including last year's nuclear pact with Tehran.
He noted areas where compromise was possible with Republicans in Congress including criminal justice reform, trade and poverty reduction.
He called for lawmakers to ratify a Pacific trade pact, advance tighter gun laws and lift an embargo on Cuba.
The president also said he regretted not having been able to elevate U.S. political discourse during his time in office.
"It's one of the few regrets of my presidency - that the rancor and suspicion between the parties has gotten worse instead of better," he said.
To help "fix" U.S. politics, Obama pressed for an end to "gerrymandering," the practice of drawing voting districts in ways that gives advantage to a particular party; reducing the influence of "dark money" or political spending in which funding sources do not have to be disclosed; and making voting easier.
Obama also said he had tasked Vice President Joe Biden, whose son died last year of cancer, to lead an effort to find a cure for the disease.
The president noted some outstanding promises from his own 2008 campaign. He pledged to continue to work to close the U.S. prison at Guantanamo Bay, Cuba, and called on Congress to lift the embargo on the Communist-ruled island nation.
Obama, whose 2008 victory was driven partially by his opposition to the Iraq war, said the United States could not serve as policeman of the world.
"We also can't try to take over and rebuild every country that falls into crisis, even if it's done with the best of intentions," he said. "It's the lesson of Vietnam; it's the lesson of Iraq; and we should have learned it by now."
Obama is eager for a Democrat to win the White House to preserve his legacy, but anger over his policies and fears about security threats have helped push non-traditional candidates to the fore in the Republican and, to a lesser extent, the Democratic races to succeed him.
Trump and Senator Ted Cruz of Texas are at the top of the Republican field, while self-described "socialist" Bernie Sanders, a U.S. senator from Vermont, is giving former Secretary of State Hillary Clinton tough competition in early voting states for the Democratic primary contest.
(Additional reporting by Richard Cowan, Julia Edwards, Ayesha Rascoe and David Lawder; Editing by Peter Cooney)