But while the climate for Mr. Obama has improved since midsummer, and Mr. Romney has failed to shift sentiment decisively in his favor, the poll found that the presidential race is narrowly divided. The outcome could still turn on unexpected events and how the candidates are perceived after their three debates next month…

The president holds a 10-point advantage on who would do a better job handling foreign policy, with 4 in 10 voters very confident of Mr. Obama’s ability to handle an international crisis, compared with about one-quarter who say the same about Mr. Romney. The survey was largely conducted before foreign affairs took on heightened importance when the United States ambassador to Libya and three other Americans there were killed on Tuesday…

The president’s job approval rating of 51 percent among all Americans marks the first time he has surpassed a majority in the poll by The Times and CBS News since immediately after Osama bin Laden was killed, in May 2011. The number of adults who say the country is on the right track has increased to 40 percent, though 54 percent say it is on the wrong track.