Baricitinib works by inhibiting Janus kinase enzymes, specifically JAK1 and JAK2. By blocking these enzymes, baricitinib reduces the activity of the immune system, thereby decreasing inflammation and autoimmune responses. This mechanism of action can be beneficial in treating a variety of inflammatory and autoimmune conditions.