  The brightest long gamma-ray burst detected so far by the Swift-BAT and
Fermi-GBM telescopes, GRB~221009A, provides an unprecedented opportunity for
understanding the high-energy processes in extreme transient phenomena. We find
that the conventional leptonic models, synchrotron and
synchrotron-self-Compton, for the afterglow emission from this source have
difficulties explaining the observation of $\gtrsim 10$ TeV $\gamma$ rays, by
the LHAASO detector, and extending up to 18 TeV energies. We model $\gamma$-ray
spectrum estimated in the energy range 0.1-1 GeV by the Fermi-LAT detector. The
flux predicted by our leptonic models is severely attenuated at $> 1$ TeV due
to $\gamma\gamma$ pair production with extragalactic background light, and
hence an additional component is required at $\gtrsim 10$ TeV. Ultrahigh-energy
cosmic rays can be accelerated in the GRB blastwave, and their propagation
induces an electromagnetic cascade in the extragalactic medium. The line of
sight component of this flux can explain the emission at $\gtrsim 10$ TeV
detected by LHAASO, requiring a fraction of the GRB blastwave energy in
ultrahigh-energy cosmic rays. This could be an indication of ultrahigh-energy
cosmic-ray acceleration in GRBs.
