COLUMBUS, Ohio — Acknowledging that commencement addresses are no place for partisanship, President Obama nonetheless skirted close to that political line on Sunday, telling graduates at Ohio State University to ignore antigovernment voices that “gum up the works” and instead aspire to be citizens who value both individual rights and community responsibilities.

“Unfortunately, you’ve grown up hearing voices that incessantly warn of government as nothing more than some separate, sinister entity that’s at the root of all our problems,” Mr. Obama told the crowd at the Ohio State commencement ceremony. “Some of these same voices also do their best to gum up the works; they’ll warn that tyranny is always lurking just around the corner. You should reject these voices.”

Ohio State graduates, their families and friends — almost 60,000 people in all — turned the university’s huge football stadium into a sea of red and gray, the university’s colors. Mr. Obama noted that it was his fifth visit to the campus in the past year, reflecting the importance of Ohio and young voters to his re-election in November.

But this was the president’s first trip here in his young second term, which has already faced setbacks in Congress over the budget and legislation to reduce gun violence and is now confronting the escalating violence in the Middle East and a push to overcome Republican opposition to an overhaul of immigration law that would provide a path to citizenship to about 11 million people who are in the country illegally.