PHILADELPHIA — The African Methodist Episcopal Church, founded by a freed slave who created a new religion rather than endure racism from white worshippers, marked its bicentennial in its birthplace of Philadelphia.

Some 30,000 people attended the AME Church’s general conference, which started July 6 and ended Wednesday.

From its roots more than 200 years ago, the African Methodist Episcopal Church has been embedded in the struggle for freedom and equality, and draws on its rich past to remain a powerful political and religious force in American culture.

“There’s a recognition that this is a denomination that represents African-American excellence, independence and autonomy,” said AME historian Christina Dickerson Cousin. “The AME Church is pretty much as old as the country itself. What other African-American institution can say that?”

Today, the AME Church boasts more than 2.5 million members, with 6,200 congregations in 39 countries. It began with a handful of free blacks determined to start their own church, rather than endure the indignities of racism.

Richard Allen was born into slavery in Philadelphia in 1760 before buying his freedom in Delaware before he was 20 years old. He returned to the city in the 1780s and became a minister. After white leaders at a Methodist church attempted to oust Allen and several other black worshippers from a service during prayer, the group left the church and formed what would eventually become Bethel AME in 1816.

Known as Mother Bethel because of its history, the church was a stop on the Underground Railroad, on which Harriet Tubman led hundreds of enslaved blacks to freedom. After the Civil War, the AME Church founded several historically black colleges, including Morris Brown College in Atlanta, Paul Quinn College in Dallas and Wilberforce University in Ohio. The AME Church was also central to the civil rights movement, serving as a meeting place and rallying point for foot soldiers.

Presidents, first ladies and presidential candidates have frequented AME churches and conferences. Last year, President Obama spoke at Mother Emanuel AME Church in Charleston after nine of its worshippers were killed during their regular Wednesday night Bible study meeting by a white gunman who specifically targeted the church for its history of rebellion and independence. Its pastor, the Rev. Clementa Pinckney, was also a state legislator.

“That shooting was probably a reminder to the church, especially, that we haven’t come as far as we would’ve liked on the issue of race,” said University of Pennsylvania religious studies professor Anthea Butler. “Part of the creation of the AME Church was about racism to begin with. It shows the connection between the political and the social, but that’s part of the history.”

The church stands today as an example for social justice leadership, said the Rev. Mark Tyler, Mother Bethel’s current pastor.

“Richard Allen was ‘Black Lives Matter’ before there was ‘Black Lives Matter,’ ” Tyler said, referring to the movement launched in recent years around the police shootings of largely unarmed black men and boys. “As opposed to simply starting a church, they began a movement. It’s not just about worship, it’s about educational opportunity, economic empowerment and raising the community. Self-determination is so critical to our identity.”

The church remains engaged in activism. During this week’s convention, pastors participated in marches to protest the deaths of two black men shot by police in Baton Rouge, Louisiana, and Falcon Heights, Minnesota.

As part of its bicentennial celebration, a statue of Allen was unveiled last week at Mother Bethel, and a mural of Allen is now on the organization’s First District building in Philadelphia. Earlier this year, the Postal Service also dedicated a stamp to Allen.