President Obama challenged Congress on Tuesday night to assist an American middle class squeezed by rising costs and stagnant wages, making clear that he will devote much of his second term to closing the income gap between rich and poor.

In his first State of the Union address since reelection, Obama called restoring the country’s middle-class promise “our generation’s task,” casting the ability to work and prosper as a basic American principle in jeopardy because of a changing economy and partisan dysfunction in Washington.

Arguing for an active government role to tackle inequality, Obama proposed a series of ways — some old, some new — to improve access to education and expand job training programs. He would raise the minimum wage to $9 an hour — a nearly 25 percent bump — over the next three years.

Many of his previous economic plans have stalled in a divided Congress. But speaking from a position of political strength — and facing a deficit of less than $1 trillion for the first time in his administration — Obama suggested that the American public supports many of his goals, even if many in the chamber do not.

In an hour-long address focused tightly on domestic issues, Obama also announced that he will bring 34,000 American troops home from Afghanistan over the next year, cutting the U.S. presence there by almost half.

The U.S. military mission in Afghanistan concludes at the end of 2014, and Obama intends to keep only a small force there for training and counterterrorism missions beyond that date. “After a decade of grinding war,” the president said, “our brave men and women in uniform are coming home.”

The speech, interrupted repeatedly by raucous and sometimes strictly partisan applause, was Obama’s fourth State of the Union address. He used the annual ritual to attempt to turn the page on a first term preoccupied with winding down two wars and working to repair a badly damaged economy.

“We have cleared away the rubble of crisis,” he said, “and we can say with renewed confidence that the state of our union is stronger.”

‘Unfinished’ business

Throughout the speech, however, was a warning that the nation’s progress, which he repeatedly called “unfinished,” is in peril unless Obama and Congress can work together on the economy’s behalf.

“We gather here knowing that there are millions of Americans whose hard work and dedication have not yet been rewarded,” he said. “. . . It is our generation’s task, then, to reignite the true engine of America’s economic growth — a rising, thriving middle class.”

Economic progress has been halting since he took office, and he spoke Tuesday with the looming threat to the economy of automatic spending cuts, known as sequestration, just a little over two weeks away.

Obama and congressional leaders have been unable to reach agreement on how to avert the cuts, which the president warned Tuesday would fall hardest on those who can least afford them.

He called for “bipartisan, comprehensive tax reform” and emphasized that his proposals would not add to the $854 billion deficit, only reallocate money already in the budget to finance them.

“But let’s be clear: Deficit reduction alone is not an economic plan,” Obama said. “A growing economy that creates good, middle-class jobs — that must be the North Star that guides our efforts.”

Republican lawmakers reacted coolly to Obama’s message, characterizing the program he outlined as a defense of big government at a time when they believe over-regulation and high taxes are keeping the economy down.

“But his favorite attack of all is that those who don’t agree with him, that we only care about rich people,” said Sen. Marco Rubio, the Florida Republican who delivered the GOP response. “. . . Mr. President, I don’t oppose your plans because I want to protect the rich. I oppose your plans because I want to protect my neighbors — hard-working middle-class Americans who don’t need us to come up with a plan to grow the government. They need a plan to grow the middle class.”

Unlike his second inaugural address, in which liberal social issues defined much of his message, Obama spoke directly Tuesday to a prime-time television audience about what he believes must be done to improve the economy and prepare the next generation of workers for the jobs it is creating.

He will take his message on the road over the next few days, visiting North Carolina, Georgia and Illinois to discuss various economic proposals.

The proposals include spending $40 billion to upgrade bridges as well as starting a fund, known as the Energy Security Trust, responsible for researching ways for more American cars and trucks to run on cleaner fuels.

When Obama spoke Tuesday about immigration legislation, gun control and climate change — issues that rank high on his domestic agenda — he did so by connecting them directly to the American economy.

He called on Americans to cut in half the energy wasted by homes and businesses in the next two decades, something that would benefit the environment as well as the economy. Green jobs, he said, will be the ones helping drive future employment growth.

In perhaps his most passionate moments, Obama also demanded action against gun violence as part of what he called “building new ladders of opportunity” for ­low-income communities aspiring to rise into the middle class.

He is scheduled to speak about the economic challenges facing cities at a Friday event in Chicago, his home town, where advisers say he will also discuss gun violence.

Obama has endorsed tighter restrictions on gun ownership — including a ban on assault rifles and the adoption of background checks for anyone buying a firearm — in the aftermath of the December shooting at Sandy Hook Elementary School in Newtown, Conn., where 20 children and six staff members were killed.

On Tuesday, several Democratic lawmakers brought victims of gun violence to the speech and, most notably, first lady Michelle Obama’s guest list included a teacher from Sandy Hook Elementary.

The first lady also sat with a police officer, Brian Murphy, who responded to the massacre at a Sikh temple in Wisconsin, and the parents of a girl killed by gunfire in Chicago this month. The 15-year-old girl, Hadiya Pendleton, performed with her high school’s majorette team in last month’s inaugural parade. Michelle Obama attended her funeral in Chicago this past weekend.

“The families of Newtown deserve a vote,” Obama said, much of the chamber coming to its feet. “The families of Aurora deserve a vote. The families of Oak Creek, and Tucson, and Blacksburg, and the countless other communities ripped open by gun violence — they deserve a simple vote.”

Minimum-wage hike

Obama’s proposal to raise the minimum wage from $7.25 to $9 an hour over the next three years was among several new proposals that his advisers said were designed to close the income gap.

As part of his job training initiatives, Obama proposed spending what advisers estimated to be $1 billion to build “manufacturing institutes” where private and ­public-sector agencies, including the Defense Department and Energy Department, collaborate to prepare workers for the challenges of the new economy.

Obama also reiterated his desire to address problems in the U.S. voting system, typified in the last election by the hours-long wait some voters endured to cast ballots in crowded polling stations, many in urban areas.

He mentioned the issue in his victory speech in November and on Tuesday announced a commission to study ways of making voting simpler.

It will be chaired by the lead attorney from Obama’s past campaign, Bob Bauer, and his counterpart from Republican Mitt Romney’s, Benjamin Ginsberg.

Obama spent less time on foreign policy, emphasizing the continuing fight against al-Qaeda and the impending conclusion of the war in Afghanistan — America’s longest — at the end of next year.

He also warned the leaders of Iran that “now is the time for a diplomatic solution” to avert a military confrontation over its uranium enrichment program.

Many of his foreign policy ambitions appeared aimed at improving the nation’s economy, and he mentioned the tumultuous Middle East only in a brief passage, saying he would address the region further during a visit there next month.