The officials spoke on condition of anonymity because they were not authorized to speak to the media.
The capture of the two follows the fall since Friday of the towns of Qaim, Rawah, Anah and Rutba, all of which are in the Sunni Anbar province where militants of the Islamic State of Iraq and the Levant have since January controlled the city of Fallujah and parts of the provincial capital Ramadi.
Sunni militants have seized another town in Iraq's western Anbar province, the fourth to fall in two days, officials said Sunday, in what is shaping up to be a major offensive in one of Iraq's most restive regions.
Iran's supreme leader meanwhile came out forcefully against any U.S. intervention in Iraq, accusing Washington of fomenting the unrest and appearing to quash recent speculation that the two rivals might cooperate in addressing the shared threat posed by the advance of Islamic extremists.
The militants captured Rutba, about 90 miles (150 kilometers) east of the Jordanian border, late Saturday, the officials said. Residents were on Sunday negotiating with the militants to leave after an army unit on the town's outskirts threatened to start shelling.
The towns of Qaim, Rawah, Anah and Rutba are the first seized in the mainly Sunni Anbar province since fighters from the Islamic State of Iraq and the Levant and their allies overran the city of Fallujah and parts of the provincial capital of Ramadi earlier this year.
The capture of Rawah on the Euphrates River and the nearby town of Anah appeared to be part of a march toward a key dam in the city of Haditha, the destruction of which would damage the country's electrical grid and cause major flooding.
Taking Rutba gives the insurgents control over the final stretch of a major highway to neighboring Jordan, a key artery for passengers and goods that has been infrequently used for months because of deteriorating security.
Iraqi military officials said more than 2,000 troops were quickly dispatched to the site of the dam to protect it. They spoke on condition of anonymity because they were not authorized to speak to the media.
Chief military spokesman, Lt. Gen. Qassim al-Moussawi, acknowledged the fall of the Anbar towns, saying government forces had made a tactical retreat and planned to retake them. He provided no further details.
The Islamic State and allied militants have carved out a large fiefdom along the Iraqi-Syrian border. Control over crossings like that one in Qaim allows them to more easily move weapons and heavy equipment. Rebels control the Syrian side of the crossing.
Prime Minister Nouri al-Maliki's Shiite-dominated government has struggled to push back against the Sunni militants, who have seized large swaths of the country's north since taking control of the second-largest city of Mosul on June 10 as troops melted away.
Iraq has requested U.S. airstrikes to help halt the advance, but President Barack Obama has yet to order any, and has instead called on Iraqi leaders to form a more representative government in thinly-veiled criticism of al-Maliki.
The top leader of neighboring Iran, which has strong influence over Baghdad, on Sunday said he was opposed to any U.S. intervention in the country.
"We strongly oppose the intervention of the U.S. and others in the domestic affairs of Iraq," Ayatollah Ali Khamenei, who has the final say over state policy, was quoted as saying by the IRNA state news agency, in his first reaction to the crisis.
"The main dispute in Iraq is between those who want Iraq to join the U.S. camp and those who seek an independent Iraq," said Khamenei. "The U.S. aims to bring its own blind followers to power."
The U.S. has long accused Iran of meddling in Iraq, including by organizing and backing Shiite militias following the 2003 invasion.
The commander of Iran's elite Quds Force, Gen. Ghasem Soleimani, was reportedly in Iraq last week to consult with the government on how to stave off insurgents' gains. Soleimani's forces are a secretive branch of Iran's Revolutionary Guard that were allegedly involved in organizing the anti-U.S. militias and have more recently aided Syria's President Bashar Assad in his fight against Sunni rebels.
Al-Maliki, who has led the country since 2006 and has not yet secured a third term after April's parliamentary elections, has increasingly turned to Iranian-backed Shiite militias and volunteers to bolster his beleaguered security forces.
Thousands of Shiite militiamen paraded through Baghdad and other cities on Saturday, brandishing a massive arsenal that included field artillery, rocket launchers and heavy machine guns in a show of force that promised to ramp up sectarian tensions.
In Baghdad, about 20,000 militiamen loyal to anti-U.S. Shiite cleric Muqtada al-Sadr, many in military fatigues, marched through the sprawling Shiite Sadr City district, which saw some of the worst fighting between Shiite militias and U.S. soldiers before a cease-fire was reached in 2008 that helped stem the sectarian bloodshed that was pushing the country to the brink of civil war.
Al-Maliki has come under growing pressure to reach out to disaffected Kurds and Sunnis, with many blaming his failure to promote reconciliation for the country's worst crisis since the U.S. military withdrew its forces nearly three years ago.
Grand Ayatollah Ali al-Sistani, the most respected voice for Iraq's Shiite majority, who normally stays above the political fray, on Friday joined calls for al-Maliki to reach out to the Kurdish and Sunni minorities.
Al-Maliki's State of Law bloc won the most seats in the April vote, but his hopes to retain his job have been thrown into doubt, with rivals challenging him from within the broader Shiite alliance.
The U.S., meanwhile, has been drawn back into the conflict. It is deploying up to 300 military advisers to join some 275 troops in and around Iraq to provide security and support for the U.S. Embassy and other American interests.
President Barack Obama, in an interview with CBS' "Face the Nation" airing Sunday, warned that the al-Qaida-inspired militants in Iraq could grow in power and destabilize the region.
He said Washington must remain "vigilant" but would not "play whack-a-mole and send US troops occupying various countries wherever these organizations pop up."
Iraq enjoyed several years of relative calm before violence spiked a year ago after al-Maliki moved to crush a Sunni protest movement against alleged discrimination and abuse at the hands of his government and security forces.
Associated Press writer Nasser Karimi in Tehran, Iran contributed to this report.
Copyright 2014 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.