Saudi Arabian authorities detained two of the kingdom’s most prominent figures for an alleged coup attempt, further consolidating the power of the king’s son, Crown Prince Mohammed bin Salman, and clearing away once-formidable rivals to the throne, according to people familiar with the matter.

The detentions occurred early Friday morning when guards from the royal court wearing masks and dressed in black arrived at the homes of the two men, took them into custody and searched their homes, according to people familiar with…