Speaking at a joint news conference at the White House, Mr Obama said they had agreed that neither country would engage in cyber economic espionage.
The deal covers the theft of trade secrets but not national security information.
President Xi also pledged to limit greenhouse gas emissions.
Mr Obama said any escalation in China's alleged cybercrimes against the US would prompt sanctions.
"It has to stop," he said. "The question is now, are words followed by action?"
Reflecting on the use of sanctions against either individuals, businesses or state-run companies, he said: "We will apply those, and whatever other tools we have in our tool kit, to go after cybercriminals either retrospectively or prospectively."
Both countries deny taking part in the cybertheft of commercial secrets.
The Chinese president said the two countries would not "knowingly support" such practices and said they would both abide by "norms of behaviour" in cyberspace.
"Confrontation and friction are not the right choice for both sides," said Mr Xi, speaking through a translator.
The cybertheft of intellectual property designed to benefit Chinese industry was described by former National Security Agency Director Keith Alexander as "the greatest transfer of wealth in history".
US officials have alleged that the Chinese state was behind a massive data security breach of government databases as well as attacks on private firms. That kind of breach is not covered by this deal.
Chinese President Xi Jinping wore a dark suit and stood at a podium during lunch at the US state department.
Behind him were his hosts, US Vice-President Joe Biden and US Secretary of State John Kerry. The room was filled with current and former officials, including Henry Kissinger.
The tables were decorated with red cloth napkins and yellow roses. Outside protesters shouted in front of the building: "Shame on the Chinese government".
Inside the room President Xi said he and President Obama had both "demonstrated a firm commitment" to a new model for their relationship.
He made a toast to friendship between the US and China. Most people stood up - but not everybody. People clapped, too, though not very enthusiastically.
Mr Obama thanked Mr Xi for introducing a cap-and-trade emissions trading system to limit greenhouse gas production.
The White House on Friday put out a fact sheet on the US and China's joint national carbon emissions trading scheme set to launch in 2017.
The "cap-and-trade" scheme would see Chinese companies charged to emit pollutants beyond a certain level.
China said it would commit $3.1bn to help developing countries reduce carbon emissions, along with other initiatives outlined in the fact sheet that would align China's climate work with that of the US.
There were also areas of sharp disagreement.
Mr Obama expressed concerns about the growing tensions in the South China Sea.
And he criticised China's human rights record, saying that preventing lawyers, journalists and others from operating freely is an obstacle to China living up to its potential.
US President Barack Obama and Chinese President Xi Jinping have said they will take new steps to address cybercrime.