NEW DELHI — Narendra Modi, who crushed doubts about his place as one of India’s most dominant leaders in recent history by winning another landslide victory this month, was sworn in for his second term as prime minister on Thursday, in a ceremony attended by as many as 8,000 guests.

Security remained tight around the massive presidential mansion in New Delhi, as national leaders and other dignitaries arrived. In a clear sign of the magnitude of Mr. Modi’s victory — his Bharatiya Janata Party was the first in more than three decades to win a clear majority in consecutive elections — officials said that his swearing-in was the largest event ever held on the mansion’s 300-acre grounds.

The guest list at the two-hour ceremony struck a balance between the ascent of Mr. Modi’s party as the country’s dominant political force, and Mr. Modi’s ambitions of projecting India as a global power, particularly in a region where China has made deep inroads.

The list of foreign leaders indicated that Mr. Modi would continue to focus on “neighbors first”: It included leaders from Bhutan, Mauritius, Myanmar, Nepal and Sri Lanka.