For President Obama, a politician of famous good fortune, even scandals within his administration seem well-timed.

The president has been untouched by the unfolding investigation involving former CIA director David H. Petraeus and Marine Gen. John R. Allen, the U.S. commander in Afghanistan.

Obama just won a not-so-close reelection battle and will never face another, leaving him less encumbered by the politics of the moment. The scandal hinges on a personal relationship beyond the White House and has not implicated the president or his closest advisers. And the person at the center of it — Petraeus, one of the most accomplished military officers in recent U.S. history — has been beloved by Republicans for years.

As Rep. Peter T. King (R-N.Y.), who heads the House Homeland Security Committee, put it Tuesday in an interview, “General Petraeus is not known to be any kind of Obama loyalist.

“I have not said a word critical of the president throughout this time,” said King, who often does. “But when I say there are a lot of unanswered questions, in this case, there really are. And I do believe at some point, someone dropped the ball.”

A Washington scandal is rarely helpful, and any distraction is unwelcome as Obama begins negotiations this week with congressional leaders about how to avert year-end tax increases and spending cuts that could push the economy back into recession.

But at least for the moment, as Obama prepares for his first post-election news conference Wednesday, the partisan calculus that has defined Washington for much of his first term has been scrambled.

Obama’s luck as a politician emerged with another sex scandal almost a decade ago, when, as a U.S. Senate candidate from Illinois, his popular likely Republican opponent, Jack Ryan, dropped out of the race amid reports that he made his then-wife visit sex clubs. Most recently, Hurricane Sandy arrived a week before Election Day, disrupting GOP rival Mitt Romney’s campaign at a time when he appeared to be gaining ground.

Petraeus’s precipitous fall also may provide Obama with more opportunities than problems, especially in staffing a second-term administration and in winding down the war in Afghanistan.

In the meantime, King and others ask whether anyone inside the White House knew before Obama’s victory last week about the FBI inquiry, conducted over an election-year summer, of Petraeus’s extramarital affair with Paula Broadwell, his biographer.

That is the ball that King thinks may have been dropped: inside White House knowledge during the campaign. White House officials have said they were not informed of the probe until the day after the election, when Director of National Intelligence James R. Clapper Jr. notified them.

King and others say the White House should have been told weeks earlier — by FBI Director Robert S. Mueller III or Attorney General Eric H. Holder Jr. — that the CIA director was the subject of a federal investigation.

Holder, in particular, is in the Republican cross hairs, as he has been frequently. Whether he will serve in Obama’s next term, as the president considers whether to spend his political capital on other Cabinet nominees, remains unclear.

Obama valued Petraeus, and although the general emerged during the George W. Bush administration, this president, like his predecessor, turned to him in key moments.

When Petraeus agreed at Obama’s request to head to Afghanistan in mid-2010 as commander of U.S. and NATO forces, he was celebrated on both sides of the aisle as the right officer to fix a politically unpopular war. As White House press secretary Jay Carney told reporters Tuesday, “He did not serve a party.”

Now, though, Obama may benefit from Petraeus’s abrupt departure in making the case for withdrawing U.S. troops in Afghanistan more quickly.

Petraeus advocated a more gradual drawdown, and without his influential voice inside Obama’s war cabinet, the president may have a freer hand in picking up the pace.

Asked Tuesday about what implications Petraeus’s exit may have on Afghan policy, a senior administration official said, “It’s too soon to know, but the bottom line is we’re proceeding ahead.”

Allen, too, has favored keeping U.S. troops in Afghanistan for as long as possible before the overall military mission expires at the end of 2014.

He was set to brief Obama this week on his plan to withdraw the remaining 68,000 U.S. troops in Afghanistan as he visited Washington for confirmation hearings on his nomination to head the European Command. His nomination is now on hold.

Allen, and Petraeus before him, lost a previous debate with Obama over how quickly to remove the 33,000 troops the president ordered there at the end of 2009. The two generals favored leaving those forces in place until the end of this year, but the last “surge” units returned last month.

Administration officials and outside analysts say they do not expect Allen’s problems to affect the overall war plan in Afghanistan, given that his replacement, Marine Gen. Joseph F. Dunford, has been named.

“Allen and the administration have surely hashed out their positions on this,” said Stephen Biddle, a senior fellow at the Council on Foreign Relations who has advised the military in Iraq and Afghanistan.

Obama didn’t expect to have to fill a top national security job. The vacancy may help him resolve a personnel jam in his administration at the level of deputy national security adviser.

Officials in the administration say Obama would like John O. Brennan, his chief counterterrorism adviser; Denis R. McDonough, one of Obama’s closest and longest-serving advisers; and Antony J. Blinken, Vice President Biden’s national security adviser whom Obama respects, to remain for a second term.

But it is time for each to advance, and there are not necessarily enough higher-level jobs for them to do so. Petraeus’s departure may make room for one.

It is possible that Obama will nominate acting CIA Director Michael J. Morell for the post. The president also could tap Brennan, a former senior CIA official, for the job to keep a highly trusted adviser — who is considering leaving — in the administration.

“We have a number of issues that we’re contending with,” Carney said. “The president will engage in a thoughtful process and make personnel decisions that need to be made in a timely manner. And when we have decisions to announce, we’ll announce them.”

Karen DeYoung contributed to this report.