WASHINGTON — The top American commander in the Middle East has ordered a broad expansion of clandestine military activity in an effort to disrupt militant groups or counter threats in Iran, Saudi Arabia, Somalia and other countries in the region, according to defense officials and military documents.

The secret directive, signed in September by Gen. David H. Petraeus, authorizes the sending of American Special Operations troops to both friendly and hostile nations in the Middle East, Central Asia and the Horn of Africa to gather intelligence and build ties with local forces. Officials said the order also permits reconnaissance that could pave the way for possible military strikes in Iran if tensions over its nuclear ambitions escalate.

While the Bush administration had approved some clandestine military activities far from designated war zones, the new order is intended to make such efforts more systematic and long term, officials said. Its goals are to build networks that could “penetrate, disrupt, defeat or destroy” Al Qaeda and other militant groups, as well as to “prepare the environment” for future attacks by American or local military forces, the document said. The order, however, does not appear to authorize offensive strikes in any specific countries.

In broadening its secret activities, the United States military has also sought in recent years to break its dependence on the Central Intelligence Agency and other spy agencies for information in countries without a significant American troop presence.