It will take effect from the Los Angeles Olympics.
IOC president Kirsty Coventry said the policy was "led by medical experts". BBC reported.
"At the Olympic Games even the smallest margins can be the difference between victory and defeat," she said.
"So it is absolutely clear that it would not be fair for biological males to compete in the female category. In addition, in some sports it would simply not be safe."
The IOC said eligibility for the female category would be determined by a screening to detect the SRY gene - the sex-determining region Y gene - which is part of the Y chromosome and causes male characteristics to develop.
"The IOC considers that SRY gene screening via saliva, cheek swab or blood sample is unintrusive compared to other possible methods," it said.
"Athletes who screen negative for the SRY gene permanently satisfy this policy's eligibility criteria for competition in the female category.
"Unless there is reason to believe that a negative reading is in error, this will be a once-in-a-lifetime test."
The IOC said athletes who fail the test would "continue to be included in all other classifications for which they qualify. For example, they are eligible for any male category, including in a designated male slot within any mixed category, and any open category, or in sports and events that do not classify athletes by sex."