At Madrid Barajas airport, passengers connecting between two international flights can usually stay in the transit area without going through immigration. If you connect from an international to a domestic flight, you enter the country here: you go through immigration and collect and re-check your bags.
The airport has 5 terminals or concourses (Terminal T1, Terminal T2, Terminal T3, Terminal T4, Terminal T4S).
Connecting passengers go through a transfer security screening.