The online discussion focused on jobs and the economy.
During the event, Twitter "curators" helped select questions for the president that were representative of the most popular topics submitted online, said the White House.
The questions had a 140-character limit, but Obama's responses did not have such a word cap. The president went the more traditional route and answered verbally in front of a live audience gathered in the East Room of the White House.
The town hall marked the first White House "Tweetup," an in-person gathering of people who are connected through Twitter.
The White House invited about 30 people who follow the administration's official Twitter account, @WhiteHouse, to come to Washington to take part in Wednesday's event. The invitees will also meet with senior administration officials following the town hall to share their thoughts on the issues that are important to them, the White House said.
Obama has taken questions from the public via social media, including Twitter, before. In April, he took part in a town hall hosted by Facebook.
White House communications director Dan Pfeiffer said the president sees social media as a way to reach beyond the mainstream media and connect with voters outside of Washington.
Twitter users were asked to submit questions using the hashtag #AskObama.
Hours ahead of the town hall, questions were coming in from some of Obama's political rivals. House Speaker John Boehner, who goes by the Twitter handle @SpeakerBoehner, asked "Will you take tax hikes off the table, or tell the American people how raising taxes will create jobs?"
"This is a slightly skewed question," Obama said of his political rival's inquiry.
The president went on to answer Boehner's question by noting that the economy is, in fact, creating jobs, though not at a pace anyone should be satisfied with. He said there was more the government could do to boost the economy but also said he hasn't always been able to get Republican support for doing so.
Republican presidential hopeful Mitt Romney - @MittRomney - stuck with the same theme, asking simply, "Where are the jobs?"
Obama also used the town hall as an opportunity to deliver a remarkably critical line about Republicans who are fighting with him over raising the nation's borrowing limit. Obama said GOP lawmakers should not use their votes on that matter as "a gun against the heads of the American people" to retain the tax breaks they want for corporate jet owners and oil companies.
The president took a total of 18 questions from the Twitterverse.
The Associated Press contributed to this report.