WASHINGTON - Sen. John Kerry ruled out a second presidential bid yesterday, saying he could do more to change the course of Iraq policy in the Senate than by campaigning in Iowa and New Hampshire.

"I've concluded this isn't the time for me to mount a presidential campaign," the Massachusetts Democrat said on the Senate floor. "I intend to work here to change a policy in Iraq that threatens all that I have worked for and cared about since I came home from Vietnam."

Since his 2004 loss to President Bush, Kerry had left open the possibility of another run for national office. He had emerged as one of the most vociferous voices in opposition to the war in Iraq and spent much of the 2006 election campaign traveling the country in support of Democratic candidates.

Much of that work was forgotten when, a little more than a week before the election, he made a remark that Republicans said disparaged U.S. troops in Iraq. He insisted it was nothing more than a botched joke but quickly apologized.

Several people close to Kerry said he struggled with the decision over whether to run again, weighing the narrowness of his 2004 defeat against the obvious hurdles presented by a Democratic field filled with figures such as Sen. Hillary Rodham Clinton of New York, Sen. Barack Obama of Illinois, and former Sen. John Edwards of North Carolina.

Kerry acknowledged as much in his remarks, saying: "We came close, certainly close enough to try again."

The sources said his decision was not motivated by national and state polling that showed him trailing Clinton, Obama and Edwards in hypothetical 2008 matchups, pointing out that Kerry had nearly $13 million in the bank that could have been used to reintroduce himself to voters. But there also were concerns that a second national candidacy could endanger Kerry's standing in his home state as well.

"Like a very smart fighter, [Kerry] made the best long-term decision for himself and the country by recognizing where the real battlefield is on the Iraq war," said Jenny Backus, a former Kerry adviser who is currently neutral in the 2008 race.

Kerry, 64, is expected to run for a fifth Senate term in 2008 and made clear during his speech that he would continue to oppose the foreign-policy course pursued by the Bush administration.

"It's not enough for Congress to go on record opposing the President's reckless plan," Kerry said, asserting that he supported a measure that would require congressional authorization for further troop buildups in Iraq.