A Muslim teenager arrested after a Texas teacher mistook his homemade clock for a bomb won invitations to the White House, Google and Facebook in a surge of public support.

President Barack Obama congratulated Ahmed Mohamed, 14, on his skills in a pointed rebuke to school and police officials — who defended his arrest — amid accusations of Islamophobia.

“Cool clock, Ahmed. Want to bring it to the White House? We should inspire more kids like you to like science. It’s what makes America great,” Obama tweeted.

A photo of Mohamed standing in handcuffs while wearing a t-shirt with the US space agency NASA’s logo was retweeted thousands of times in a matter of hours and “#IStandWithAhmed” became the top trending hashtag on Twitter.

Mohamed told the Dallas Morning News he hoped to impress teachers by bringing the clock to school on Monday.

“I made a clock. It was really easy. I wanted to show something small at first… they took it wrong so I was arrested for a hoax bomb.”

The son of Sudanese immigrants who live in a Dallas suburb, Mohamed loved robotics club in middle school and was hoping to find something similar at MacArthur High School. He did not get the reaction he hoped for when he showed the clock to his engineering teacher.

“He was like, ‘That’s really nice,'” Mohamed said. “‘I would advise you not to show any other teachers.'”

When the clock’s alarm went off in another class, the teacher told him it looked like a bomb and confiscated it. The school called police and Mohamed was taken away in cuffs amid suspicion he intended to frighten people with the device.

Police said Wednesday they have determined that Mohamed had no malicious intent and it was “just a naive set of circumstances.”

Irving police chief Larry Boyd insisted that Mohamed’s ethnicity had nothing to do with the response.

“Our reaction would have been the same either way. That’s a very suspicious device,” Boyd told reporters.

“We live in an age where you can’t take things like that to school.”

A school district spokeswoman also stood by the establishment’s response, telling reporters that anyone who saw the homemade clock would understand that “we were doing everything with an abundance of caution.”

A photo provided by police showed a flat, rectangular red digital clock face screwed into the dark plush interior of a silver case along with a circuit board and some wires.

“My son is a very brilliant boy,” Mohamed Elhassan Mohamed — who has run for president in Sudan — told CNN.

White House spokesman Josh Earnest called the incident an opportunity to “search our own conscious for biases that might be there.”

“At least some of Ahmed’s teachers failed him,” he said, adding that “this has the potential to be a teachable moment.”

The Council on American-Islamic Relations said the heavy-handed response was suspicious given the political climate in Irving — where mayor Beth Van Duyne has claimed that Muslims are plotting to impose Sharia law — and across the nation.

“Clearly we believe it’s the result of the rising level of anti-Muslim sentiment in our society,” CAIR spokesman Ibrahim Hooper told AFP.

“It’s clear that if it was some student who wasn’t named Ahmed Mohamed and didn’t have brown skin, he would not have been forced to do a perp walk in front of his fellow students in handcuffs.”

Wired magazine was among those who responded to the incident with a mixture of humor and horror, posting an article entitled “How to Make Your Own Homemade Clock That Isn’t a Bomb.”

Zuckerberg may have to wait.

Along with the invitation to astronomy night at the White House next month, Mohamed also got invitations to drive NASA’s Opportunity rover, tour MIT, intern at Twitter and visit Google.

“Hey Ahmed- we’re saving a seat for you at this weekend’s Google Science Fair…want to come? Bring your clock!” the online giant tweeted.

Canadian astronaut Chris Hadfield invited Mohamed to his science variety show, and the Four Seasons hotel responded with an offer of a free room in Toronto.

Mohamed’s family launched a Twitter account to thank his supporters using @IStandWithAhmed as his handle.

“Thank you fellow supporters. We can band together to stop this racial inequality and prevent this from happening again,” read a tweet that included a photo of the smiling boy in his NASA t-shirt holding two fingers up in the sign of victory.

The hashtag #IStandWithAhmed had been tweeted more than 800,000 times by Wednesday afternoon, according to analytics site Topsy.com.