As per Enforcement Instructions and Guidance c56 s1:
Whilst a person who is served with a notice of illegal entry, notice
of administrative removal, or is the subject of deportation action is
liable to detention, such a person may, as an alternative to
detention, be granted temporary admission or release on restrictions
What this means in human terms is that once a decision for refusal was made the officer can choose to detain the person, or grant them temporary admission. So to be given a temporary admission, you must fail to obtain immigration clearance in the first place, which means that you were refused and there will be a stamp in your passport to reflect this.
Whether it will be granted is entirely at Immigration Officer's discretion, you should always put the best possible case to be admitted in another category when faced with a refusal. The best working example is to be admitted as an air side transit passenger, but commonly people are too upset to think about viable alternatives.
More than any other factor, the outcome of an event with a British Immigration Officer is influenced by personal impact and articulation skills. It's also a great reason to remain civil, objective and try to control oneself when your interview goes wrong. There was one case of exactly that happening the UK Border Force Season 2 Episode 10 (as much as anecdotal sources count), where a person who kept his cool and continued to present his case managed to gain temporary admission.
The maximum allowable period for temporary admission is 6 months.