The attack was also the latest in a series of assaults over the past year that challenged the pro-Western kingdom’s claim to be an oasis of calm in a region increasingly threatened by Islamic extremists.