Two decades of praying, planning and building came to fruition Saturday as thousands from across the country and beyond gathered to celebrate the official opening of a $110 million facility in suburban Maryland designed to support and honor Turks and those of the Muslim faith living in the United States.

The Diyanet Center of America, which bills itself as the largest Islamic campus “in the Western Hemisphere,” welcomed Turkish immigrants from Canada and Muslims from the Washington region to the facility, which includes a 20,236-square-foot mosque, a cultural center, guest quarters and an underground sports complex.

Turkish President Recep Tayyip Erdogan, who has been a big backer of the cultural center, was the featured speaker. He spoke of the more than 20-year effort to complete the complex.

“I was dreaming of this day,” Erdogan said. He recalled the old building used as a mosque that sat on the land in Lanham for years and the long wait for the buildings to be finished. But as he looked out at the center on Saturday, he said, “This is not a picture. This is not a landscape. This is a reality.”

The center opens at a time of heightened fears about Muslims and anti-Islam rhetoric by presidential campaigns. Security was heavy, with officers from the Prince George’s police department in attendance, alongside Erdogan’s security detail from Turkey and Turkish American members of the New York City Police Department.

Erdogan devoted most his speech to defending his country, which has been criticized for its treatment of Kurdish groups, and Islam, which has been blamed for the rise of Islamist militants.

“Terrorism will never have a religion, a nation or a nationality,” Ergodan said, speaking in front of the center’s towering mosque. “There is terrorism in Brussels, terrorism in Paris. We have been fighting against terrorism for the last 35 years.”

Erdogan arrived in Washington last week for the Nuclear Security Summit. His speech at the Brookings Institution on Thursday was overshadowed by protests and video of his security detail tussling with journalists. Erdogan’s harsh tone, challenging the loyalty of Turkish reporters who have written articles critical of him, did little to improve his standing among many in the United States.

But Turkey’s president was well received by those who came to celebrate the opening of the center. He got some of his loudest applause when he told people to be proud of their Islamic heritage. He said Muslims should not be forced into choosing between “being a Muslim and being an American.”

Selami Sahin, treasurer of the Turkish Association of Canada in Ottawa, drove 10 hours with his wife and three children to attend the opening. He said his group hopes to build a similar compound in Canada. “The artwork in this day and time, to build something like this is incredible,” he said.

Erdogan ended his address with an invitation to those not in attendance.

Turkish President Recep Tayyip Erdogan, who has been a big backer of the cultural center, was the featured speaker. (Linda Davidson/The Washington Post)

“Join us against a common fight against hatred and prejudice,” he said. “Islam is a religion that commands living and not dying. This cultural center will serve all of these valuable purposes.”

After the official ceremony, Erdogan moved through the crowd. There he came upon 12-year-old Semera Saydam. She wanted a selfie with the Turkish president. There wasn’t time, but Erdogan did sign a piece of paper she managed to slip through to him.

“This means the world to me,” said Semera’s father, Nejder Zafer Saydam. “We came to this country 47 years ago. I think our president . . . is showing the world what Turkey is all about.”