Gunmen opened fire on vehicles carrying mainly Shiite Muslims on a key highway in Pakistan's restive northwest on Thursday, killing at least 38 people and wounding 20 others, police said.