President Donald Trump is trying to follow through on one of his campaign promises by ending birthright citizenship, a 150-year-old law established in the Constitution that grants U.S. citizenship to anybody born on U.S. soil.

The law has been the target of anti-immigration groups for years, who say it has been abused by undocumented immigrants and companies that peddle “birth tourism.” But birthright citizenship is now ingrained in multiple U.S. laws, the Constitution, and been upheld by the Supreme Court.

Trump’s announcement that he will end the practice through an executive order just days before the midterm elections is sure to draw immediate legal challenges that could lead all the way to the Supreme Court. For now, here’s a look at some of the key aspects of birthright citizenship.

What is birthright citizenship?

The principle that anybody born on U.S. soil becomes a U.S. citizen.

It was added to the Constitution in 1868 in the first sentence of the 14th Amendment, which reads: "All persons born or naturalized in the United States, and subject to the jurisdiction thereof, are citizens of the United States and of the State wherein they reside."

The amendment was designed to grant citizenship to freed slaves after the Civil War, overriding the Dred Scott v. Sandford decision by the Supreme Court that had forbidden African-Americans from ever gaining citizenship and the Naturalization Act of 1790 that conferred citizenship only on free white persons "of good character."

In practice, it has become a bedrock of U.S. immigration law that has allowed anybody born in the U.S. to become citizens. Congress also has passed laws extending birthright citizenship to people born in U.S. territories, including Puerto Rico, Guam and the U.S. Virgin Islands.

How many people benefit?

Citizenship was granted to about 275,000 babies born to undocumented immigrant parents in 2014, representing about 7 percent of all births in the country that year, according to an analysis by the nonpartisan Pew Research Center.

Those numbers represented a drop from the peak years of illegal immigration, topped in 2006 when about 370,000 children were born to undocumented immigrants, or 9 percent of all births, according to the Pew estimate.

Data from Pew shows that 90 percent of undocumented immigrants who give birth in the U.S. arrived in the country more than two years before giving birth.

Those numbers do not include pregnant mothers who obtain visas to travel to the U.S. shortly before giving birth. Russians routinely fly to South Florida, and there is an entire industry in China designed to coach pregnant women on how to deal with U.S. immigration authorities so they can enter the United States for the sole purpose of giving birth to American citizens.

Mexicans also contribute a large share: 21 percent of births in Arizona in 2014 were to undocumented immigrants, and 25 percent of births in Texas that year were to undocumented immigrants, according to an analysis by the Center for Immigration Studies, a group that opposes birthright citizenship and advocates for lower levels of legal and illegal immigration.

Altogether, the center puts the total number of babies born through birth tourism at about 36,000 a year.

How many countries grant it?

Trump has said the U.S. is the only nation in the world to grant birthright citizenship. The Center for Immigration Studies identified at least 30 nations that grant birthright citizenship, however, including Canada, Mexico, Brazil, Argentina and Chile.

John Skrentny, a sociologist at the University of California-San Diego, told Politifact in 2015 that birthright citizenship is a holdover from colonial times, when European countries granted lenient naturalization laws in order to conquer new lands. That's why the practice is almost exclusively used in the Western Hemisphere.