BARCELONA, Spain — The attacks in and near Barcelona initially led rival Spanish and Catalan politicians to present an image of solidarity in the face of terrorism.

King Felipe VI and Prime Minister Mariano Rajoy attended solemn commemorations in Barcelona for victims. Mr. Rajoy even held a news conference with Carles Puigdemont, the Catalan leader, whom he had not met officially since April of last year.

But with the end of the hunt for the assailants this week, the tensions that had been masked by the facade of unity are now threatening to boil over, as the political clock ticks toward a Catalan independence referendum scheduled for Oct. 1. Mr. Rajoy has threatened to block that vote with the help of Spanish courts.

The attacks that killed 15 people last week “occurred at the worst moment of the relationship between Catalan and Spanish politicians, and the only thing this has done is to add more tensions below the surface,” said Ramon Perelló, the head of Península, a Barcelona-based publisher.