BAGHDAD  Secretary of State Condoleezza Rice made an unannounced visit to Iraq on Tuesday, visiting the oil-rich city of Kirkuk and then Baghdad, as tensions mounted along the country’s mountainous border with Turkey.

Shortly before the visit, Turkish troops staged a brief cross-border attack into northern Iraq to strike at a group of Kurdish militants there. The Turkish military, in a statement on its Web site, said its troops had inflicted heavy losses on the fighters after spotting them trying to cross into Turkey on Monday night.

American military officers in Washington and overseas said that the Turkish ground force sent across the border numbered only in the hundreds and that it moved fewer than two miles into Iraqi territory. Turkey said only that it was a “small-scale operation,” and indicated that the troops quickly returned to Turkey.

“Nothing the Turks have done to date should be considered a surprise,” said an American military officer, who spoke on the condition of anonymity because he was discussing actions of a sovereign ally. “We’ve shared information as we said we would do. The decision to pursue military options is theirs.” American officials said the Turkish operation appeared to be over.