Attack move

Attack-Move causes the selected group to move to a location. If any enemies are encountered along the way, the group will attack that enemy until it is killed. They will repeat this until all encountered enemies are dead, then resume moving to their original destination.

To attack move a group type 'A' or select the attack move button from the lower-right, and then left-click on the destination. The attack move is one of the basic skills players must learn when playing StarCraft or StarCraft II; if they use the "move" command instead, their armies will march right past enemy units without stopping or retaliating to damage, a potentially disastrous maneuver.

However, there are incidents in which a player should use move rather than attack move. Examples include rushing past base defenses to attack more important units and structures, retreating from a more powerful enemy army, and using units to serve as a distraction rather than a threat.

In StarCraft II, there is an alternate way to attack move; hold ctrl while right-clicking the ground.[1]
If the units approach a mix of different units, the AI will attack the biggest threat to them first.

Non-attacking spellcasting units have a similar command, called Scan Move.