Definition: Granuloma is a medical term for a ball-like collection of immune cells which forms when the immune system attempts to wall off substances that it perceives as foreign but is unable to eliminate. These substances include infectious organisms ,such as bacteria and fungi, but also other materials that the body cannot process such as keratin or suture fragments. A granuloma just a special type of inflammatory reaction.
Granulomas also occur in many different types of diseases, including those not associated with infection (bacteria, fungi, viruses). Physicans will use the term "granuloma" loosely in many instances, and often are just referring to a small nodule, especially on radiographs. Because this term is so loosely utilized, it is difficult to determine if the granuloma referred to is a harmless nevus or a malignant tumor. The correct use of the term "granuloma" requires a pathologist to examine surgically removed and specially colored (stained) tissue under a microscope. 
In pathology, a granuloma is an organized (tight ball) collection of macrophages.  Macrophages (also known as histiocytes) are the cells that define a true granuloma. These cells often fuse to form giant cells, which are multiple granulomas together. The macrophages in granulomas are often referred to as "epithelioid due to the vague resemblance of these macrophages to epithelial cells. Epithelioid macrophages differ from ordinary macrophages in that they have elongated nuclei  and also larger nuclei than ordinary macrophages. Also, histologically they can be distinguished because their cytoplasm is typically more pink when stained with eosin. The macrophages in these formations are typically so tightly clustered that the borders of individual cells are difficult to appreciate when examined under a microscope. Loosely dispersed macrophages are not considered to be granulomas. 
Causes of Granulomas
The difference between granulomas and other types of inflammation is that granulomas form in response to antigens that are resistant to the first line of defense in the body. This consists of inflammatory cells such as neutrophils and eosinophils. The antigen causing the formation of a granuloma is most often an infectious pathogen or a substance foreign to the body, but often the offending antigen is unknown (as in sarcoidosis). 
Some granulomas contain necrosis (dead cells that appear as a mass of formless debris with no nuclei present). Some also have "caseation" (literally: turning to cheese) which is a form of necrosis that without a microscope, appears cheese-like (caseous), and is typically a feature of the granulomas of tuberculosis.  The identification of necrosis in granulomas is important because granulomas with necrosis usually have infectious causes.
Diseases Associated with Granulomas
Granulomas are seen in a wide variety of diseases. Infections that are characterized by granulomas include tuberculosis, leprosy, histoplasmosis, cryptococcosis, coccidioidomycosis, blastomycosis and cat scratch disease. Some more common non-infectious granulomatous diseases inculde sarcoidosis, Crohn's disease, , Wegener's granulomatosis, Churg-Strauss syndrome, pulmonary rheumatoid nodules, berylliosis, and aspiration pneumonia. 
The most common cause of lung granulomas is histoplasmosis, a fungal infection.  This is usually diagnosed via X-rays because granulomas become calcified and can be seen. 
Diseases associated with granulomas each have a different preferred method of treatment, and because granulomas are so wide-spread the possibilities for treatment are almost limitless. Acute infections should be treated aggressively with antibiotics, and these can also be prescribed prophylactically to prevent infection. If an abscess forms in association with the granuloma it can be treated and drained by a surgeon.