By Tom Perry

RAMALLAH, West Bank (Reuters) - Hamas has jumped back into the Middle East spotlight with a prisoner swap deal with Israel that will score points over President Mahmoud Abbas and steal some of the thunder he generated by pushing for Palestinian statehood at the United Nations.

But the deal hailed by the Islamist group which governs Gaza as a national victory was dimmed by Israel's refusal to free some prominent prisoners from rival factions, chief among them Marwan Barghouti -- a leading figure in Abbas' Fatah movement.

Hamas had repeatedly pledged to secure Barghouti's release in any deal to set free Gilad Shalit, the Israeli soldier captured in 2006. Israel is now set to free more than 1,000 Palestinians for Shalit in the deal announced on Tuesday.

"They would have given up on an important person in Barghouti. Someone important to the national movement," said Hany al-Masri, a political commentator based in Ramallah in the West Bank. "It's still a victory, but not such a great one."

The exiled Hamas leader Khaled Meshaal, announcing the deal from his Damascus headquarters, said the prisoners included more than 300 serving life terms in Israeli jails. They were drawn from members of all the Palestinian factions.

But he did not name any of them, fuelling early speculation that Barghouti and Ahmed Saadat, the leader of the Popular Front for the Liberation Of Palestine, had been left out of the deal.

Meshaal described the lopsided swap as "a national achievement" for the Palestinians, whose struggle for statehood has been crippled by the divide between the Hamas-run Gaza Strip and Abbas' West Bank-based Palestinian Authority.

"This deal embodies and strengthens the unity of the people by including all the factions," Meshaal said.

Though lacking Saadat and Barghouti, the swap will resonate with Palestinians, who regard the 6,000 or more prisoners held by Israel as national heroes and freedom fighters.

From a domestic perspective, the timing comes at a good moment for Hamas. A hunger strike among Palestinian prisoners whose demands include an end to solitary confinement is making daily headlines in the Palestinian media.

ECLIPSED BY ABBAS

The prisoner swap switches attention back to the Islamist group that has appeared eclipsed in recent weeks by Abbas' drive to secure full U.N. membership for a Palestinian state in the face of stiff U.S. and Israeli opposition.

Hamas' criticism of the diplomatic move had appeared out of tune with public support that peaked with a strong speech Abbas delivered to the U.N. General Assembly on September 23.

"Hamas proves again that it has cards and they can pull them out at the speed of light," said Zakaria al-Qaq, a Palestinian political commentator. "It's about scoring goals. It isn't a matter of elections, it's about credibility."

For now, the opinion polls are of little consequence to either Fatah or Hamas: neither is likely to face an electoral test any time soon because of the division between Gaza and the West Bank. The split has persisted, despite an agreement announced in May designed to end it.

But credibility matters to both. Abbas, 76, a believer in peace negotiations despite a deadlock that has lasted over a year, has enhanced his standing in recent months, showing a more defiant approach toward Israel and the United States.

He has stuck by his commitment not to return to talks with Israel without a full halt to its settlement construction on land where the Palestinians aim to found an independent state.

And his attempt to secure U.N. membership, though doomed to failure by the prospect of a U.S. veto, has won support as a welcome change after two decades of negotiations.

Hamas' critics, meanwhile, say the movement has been facing a credibility crisis, struggling to reconcile its commitment to armed struggle against Israel with the responsibilities of governing Gaza, where it seized power from Abbas in 2007.

They have pointed to a contradiction between Hamas' words and deeds as it has sought to rein in militants whose rocket attacks into Israel have drawn punishing reprisals.

In his televised address, a defiant Meshaal promised to secure the release of more prisoners. "We met our promise to you today, and we will do so tomorrow, God willing," he said.

Talal Okal, a Gaza-based commentator, said: "This has restored the shine to Hamas."

Qaq added: "The Hamas movement is sending a message: that negotiations are not worth it, and its method, resistance, is the one that produces results."

(Writing by Tom Perry; Editing by Janet Lawrence)