UbiA prenyltransferases (PTs) play an important role in prenylation of aromatic compounds with diverse bioactivities. The deep and comprehensive understanding of their substrate selectivity and catalytic mechanism will facilitate the expansion of the robust biocatalytic tools for prenylation of aromatic compounds. Herein, we identified an atypical PHB-type UbiA PT (ClaS) from the basidiomycete Clitocybe clavipes. Unexpectedly, ClaS transferred geranyl pyrophosphate (GPP) to hydroquinone (HYQ) instead of p-hydroxybenzoic acid (PHB). Interestingly, the mutant H73R of ClaS completely switched the substrate preference from HYQ to PHB. Further, the conserved residues His and Arg at the substrate binding site were characterized as the gatekeeper residue of PHB-type UbiA PTs for recognition of the substrates HYQ and PHB, respectively. The structure of ClaS was predicted, and the substrates were docked into ClaS to investigate the catalytic and substrate selectivity mechanisms. QM calculations suggested that the proton transfer from the hydroxyl group of HYQ to the leaving pyrophosphate group may facilitate the nucleophilicity of the substrate. The structural analysis based on MD simulations showed that the pre-reaction state (PRS) occupancy in the complex WT-HYQ and mutant H73R-PHB was favorable for the formation of final products. Analysis of binding free energy further disclosed that the substrate selectivity may be controlled by the different interactions between the hydroxyl or carboxyl group of the substrate and the gatekeeper residues. Finally, we expanded the utility of ClaS by mutating the gatekeeper residue to catalyze the prenylation of various substituted-PHB analogues. Our findings reveal the molecular basis of the PHB-type UbiA PTs for recognizing and catalyzing different substrates and enable us to engineer them for the enzymatic or microbial production of prenylated aromatic compounds.