British scientists produced a working thymus, a vital immune system "nerve centre" located near the heart.
In future the technique, so far only tested on mice, could be used to provide replacement organs for people with weakened immune systems, scientists believe.
But it might be another 10 years before such a treatment is shown to be effective and safe enough for human patients.
The research by-passed the usual step of generating "blank slate" stem cells from which chosen cell types are derived.
Instead, connective tissue cells from a mouse embryo were converted directly into a completely different cell strain by flipping a genetic "switch" in their DNA.
The resulting thymic epithelial cells (TECs) were mixed with other thymus cell types and transplanted into mice, where they spontaneously organised themselves and grew into a whole structured organ.
Professor Clare Blackburn, from the Medical Research Council (MRC) Centre for Regenerative Medicine at the University of Edinburgh, who led the team of scientists, said: "The ability to grow replacement organs from cells in the lab is one of the 'holy grails' in regenerative medicine. But the size and complexity of lab-grown organs has so far been limited.
"By directly reprogramming cells we've managed to produce an artificial cell type that, when transplanted, can form a fully organised and functional organ. This is an important first step towards the goal of generating a clinically useful artificial thymus in the lab."
If the immune system can be compared with an army, the thymus acts as its operations base. Here, T-cells made in the bone marrow are primed to attack foreign invaders, just as soldiers are armed and briefed before going into battle.
Once deployed by the thymus, the T-cells protect the body by scanning for infectious invaders such as bacteria and viruses, or dangerous malfunctioning cells, for instance from tumours. When an "enemy" is detected, the T-cells mount a co-ordinated immune response that aims to eliminate it.
People with a defective thymus lack functioning T-cells and are highly vulnerable to infections. This is especially hazardous for bone marrow transplant patients, who need a working thymus to rebuild their immune systems after surgery.
Around one in 4,000 babies born each year in the UK have a malfunctioning or completely absent thymus, due to rare conditions such as DiGeorge syndrome.
Thymus disorders can be treated with infusions of extra immune cells or transplantation of a new organ soon after birth. However, such approaches are severely limited by a lack of donors and tissue rejection.
The new research, published in the journal Nature Cell Biology, raises the possibility of creating a whole new functioning thymus using cells manufactured in the laboratory.
While fragments of organs, including hearts, livers and even brains, have been grown from stem cells, no one before has succeeded in producing a fully intact organ from cells created outside the body.
The process began by taking connective tissue cells called fibroblasts from mouse embryos and "tweaking" their DNA to increase production of a protein called FOXN1. One of a family of "transcription factors" that regulate the activity of certain genes, FOXN1 guides the formation of the thymus during normal embryonic development.
Fibroblasts with boosted FOXN1 transformed themselves into "induced" TECs (iTECs). After being mixed with other, supportive thymus cells, the iTECs were grafted on to the kidneys of genetically identical laboratory mice.
After four weeks, the cells had produced well-formed organs with the same structure as a healthy thymus including defined regions known as the cortex and medulla.
The scientists wrote: "On transplantation, the iTECs established a complete, fully organised and functional thymus that contained all of the TEC sub-types required to support T-cell differentiation and populated the recipient immune system with T-cells."
Laboratory tests showed that the iTECs allowed efficient development of both of the two main kinds of T-cell, known as CD4 and CD8 T-cells.
CD4 cells, or "helper" T-cells, send out signals that orchestrate the right immune system response, while CD8 "killer" T-cells directly attack and destroy infected cells and cancer cells.
Dr Rob Buckle, head of regenerative medicine at the MRC, said: "Growing 'replacement parts' for damaged tissue could remove the need to transplant whole organs from one person to another, which has many drawbacks - not least a critical lack of donors.
"This research is an exciting early step towards that goal, and a convincing demonstration of the potential power of direct reprogramming technology, by which once cell type is converted to another. However, much more work will be needed before this process can be reproduced in the lab environment, and in a safe and tightly controlled way suitable for use in humans."
Chris Mason, Professor of Regenerative Medicine at University College London, said: "Using living cells as therapies has the big advantage in that the functionality of cells is many orders of magnitude greater than that of conventional drugs. Nowhere is this level of functionality more needed than in curing disorders of the immune system.
"The time and resources required to turn this mouse proof-of-concept study into a safe and effective routine therapy for patients will be very significant - 10 years and tens of millions of pounds at a bare minimum. Even the starting point, the underpinning science, is far from complete: for example, not all the cells that are required can yet be made in the lab. However, the... data strongly support the urgent need for more scientists, together with engineers and clinicians, to now get involved in order to evaluate and develop this new technology."
Dr Paolo de Coppi, consultant paediatric surgeon at Great Ormond Street Hospital and head of Stem Cells and Regenerative Medicine at the Institute of Child Health, London, said: "Research such as this demonstrates that organ engineering could, in the future, be a substitute for transplantation, overcoming problems such as organ donor shortages and by-passing the need for immunosuppressive therapy.
"It remains to be seen whether, in the long term, cells generated using direct reprogramming will be able to maintain their specialised form and avoid problems such as tumour formation."