KABUL, Afghanistan — American troops raked a large passenger bus with gunfire near Kandahar on Monday morning, killing and wounding civilians, and igniting angry anti-American demonstrations in a city where winning over Afghan support is pivotal to the war effort.

The shooting, which killed as many as five civilians and wounded 18, occurred on the eve of the most important offensive of the war. In coming weeks thousands of American, NATO and Afghan troops are expected to try to take control of the Kandahar region, the spiritual home of the Taliban.

It was the latest case in which NATO or American forces fired on and killed civilians near a checkpoint or military convoy because they were perceived to have come too close or to be approaching too fast.

Gen. Stanley A. McChrystal, the American and NATO commander in Afghanistan, has made reducing civilian casualties a priority, and they have gone down over the last year. But checkpoint and convoy shootings have not declined, worrying commanders who believe that such killings are turning Afghans against foreign forces.