The U.S. Department of Homeland Security has ordered new security checks for all foreign students entering the United States, according to officials familiar with instructions issued Friday to customs inspectors.

The new check was added after the authorities discovered that a foreign friend of Dzhokhar Tsarnaev, the surviving suspect in the Boston Marathon bombings, had left the United States and returned in January using a student visa that should have been canceled because he was no longer enrolled at the University of Massachusetts, Dartmouth.

The friend, Azamat Tazhayakov, is one of two students from Kazakhstan who were arrested Wednesday, charged with obstructing justice and accused of covering up evidence of Tsarnaev’s role in the bombings.

Aside from standard verification of their travel documents, arriving students now will also be checked through a database known as the Student and Exchange Visitor Information System, officials said. The system contains information on schools with foreign students and on the students’ enrollment status.

According to Homeland Security Department officials, Tazhayakov left the United States in December and returned Jan. 20, presenting a student visa with an expiration date of Aug. 30 of this year and a letter of enrollment from the University of Massachusetts.

However, officials later learned that the university had reported to the department that Tazhayakov’s enrollment had ended Jan. 4.

Students generally are allowed a 30-day grace period to re-establish enrollment before they are required to leave, the officials said. But the leeway applies only to students remaining in the country; those who fail to maintain enrollment are not allowed to leave and re-enter.

Although his visa had not expired, officials said, Tazhayakov should not have been allowed to return.

A lapse occurred because Customs and Border Protection inspectors did not have the latest information on Tazhayakov, officials said. The new entry checks, which were first reported by The Associated Press, would give airport customs officers the most recent information about students’ visa and enrollment status.

The Homeland Security Department has been working to improve the student checks system, officials said.

They said when Tazhayakov passed customs, their databases contained no information that he posed a national security threat.