An easy way is
\documentclass{article}
%\usepackage{amsthm} %% uncomment to see the difference
\newtheorem{innercustomthm}{Theorem}
\newenvironment{customthm}[1]
{\renewcommand\theinnercustomthm{#1}\innercustomthm}
{\endinnercustomthm}
\begin{document}
\begin{customthm}{8}\label{eight}
Every theorem must be numbered by hand.
\end{customthm}
Here is a reference to theorem~\ref{eight}.
\end{document}
You can also use the optional argument for attribution:
\begin{customthm}{99}[Somebody]\label{ninetynine}
Statement.
\end{customthm}
A more generic interface for defining several of these environments; this doesn't respect theorem styles; it could be adapted, though.
\documentclass{article}
\usepackage{amsthm}
\newtheorem{innercustomgeneric}{\customgenericname}
\providecommand{\customgenericname}{}
\newcommand{\newcustomtheorem}[2]{%
\newenvironment{#1}[1]
{%
\renewcommand\customgenericname{#2}%
\renewcommand\theinnercustomgeneric{##1}%
\innercustomgeneric
}
{\endinnercustomgeneric}
}
\newcustomtheorem{customthm}{Theorem}
\newcustomtheorem{customlemma}{Lemma}
\begin{document}
\begin{customthm}{8}\label{eight}
Every theorem must be numbered by hand.
\end{customthm}
Here is a reference to theorem~\ref{eight} and
one to the important lemma~\ref{life-universe-everything}
\begin{customlemma}{42}\label{life-universe-everything}
This lemma explains everything.
\end{customlemma}
\end{document}

ADDITION
Support for cleveref was asked in comments.
\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{cleveref}
\newtheorem{innercustomgeneric}{\customgenericname}
\providecommand{\customgenericname}{}
\newcommand{\newcustomtheorem}[2]{%
\newenvironment{#1}[1]
{%
\ifdefined\crefalias\crefalias{innercustomgeneric}{#2}\fi
\renewcommand\customgenericname{#2}%
\renewcommand\theinnercustomgeneric{##1}%
\innercustomgeneric
}
{\endinnercustomgeneric}%
\ifdefined\crefname\crefname{#2}{#2}{#2s}\fi
}
\newcustomtheorem{customthm}{Theorem}
\newcustomtheorem{customlemma}{Lemma}
\begin{document}
\begin{customthm}{8}\label{eight}
Every theorem must be numbered by hand.
\end{customthm}
Here is a reference to \cref{eight} and
one to the important \cref{life-universe-everything}
\begin{customlemma}{42}\label{life-universe-everything}
This lemma explains everything.
\end{customlemma}
\end{document}
The \ifdefined bits allow for the solution to be independent on cleveref.

innercustomthmis stepped, so the reference is established, but\theinnercustomthmis used, which can contain anything (well, almost). – egreg May 01 '12 at 16:50@DavidCarlisle: I went with egreg's, because it's simpler, but thanks also!
– Skeptic May 01 '12 at 17:06\begin{customthm}{\ref{oldtheorem}}\end{customthm}, but this gives me errors. How would I modify this code to achieve the desired result? – Jonathan Gleason Aug 10 '12 at 15:20\newenvironment{customthm}[2][]{\renewcommand\theinnercustomthm{#2}\innercustomthm[#1]}{\endinnercustomthm}. – equaeghe Mar 07 '14 at 15:42\newtheorem{innercustomlemma}{Lemma}and\newenvironment{customlemma}[1]{\renewcommand\theinnercustomlemma{#1}\innercustomlemma}{\endinnercustomlemma}– egreg Jul 03 '14 at 08:00\begin{customthm}{8}{-5}\label{abc} blabla \end{customthm}, I would like the theorem number to be 8, but if I do\ref{abc}, I would like -5 to be printed. – PhoemueX Jan 17 '18 at 10:22\makeatletter\newcommand\manuallabel[1]{\def\@currentlabel{#1}}\makeatletterand use\begin{customthm}{8}\manuallabel{-5}\label{abc}– egreg Jan 17 '18 at 11:41\frac{\boldsymbol{1}}{\boldsymbol{2}}. However, in references to the theorem, I would like the usual\frac{1}{2}instead of the bold fraction :) – PhoemueX Jan 18 '18 at 10:44\thehas nothing to do with this. – egreg Jun 21 '20 at 08:12restatableenvironment fromthmtoolspackage? That is, I want to make a custom-numbered theorem restatable. I can't figure out how to get the restatable environment to understand why I'm giving it an extra argument (namely, the number that I want to assign to the theorem) – Joseph Granata Feb 04 '21 at 22:20cleveref. – Hermetically Sealed Halibut Feb 02 '24 at 14:33cleveref– egreg Feb 02 '24 at 15:31