Methods are disclosed for treating or preventing graft versus host disease in a subject. The methods include selecting a subject in need of treatment for graft versus host disease; and administering to the subject a therapeutically effective amount of a TLR5 agonist such as a flagellin polypeptide, or a polynucleotide encoding the flagellin, thereby treating or preventing graft versus host disease in the subject. Methods are also disclosed for reducing susceptibility to an opportunistic infection in a subject who is a bone marrow transplant recipient. The methods include selecting a subject who has had a bone marrow or hematopoietic stem cell transplant; and administering to the subject a therapeutically effective amount of a TLR5 agonist such as a flagellin polypeptide or a polynucleotide encoding the polypeptide, and administering to the subject an effective amount antigen of the opportunistic infection, thereby reducing the susceptibility to the opportunistic infection in the subject.