India's ruling Bharatiya Janata Party (BJP) will be part of a coalition government in Indian-administered Kashmir, two months after polls there produced no clear winner.
The BJP and the People's Democratic Party (PDP) announced the deal after talks in the capital, Delhi.
It is the first time the Hindu nationalist BJP have been in government in India's only Muslim majority state.
The party won 25 seats and the PDP 28 in the 87-member state assembly.
Votes were counted on 23 December after five rounds of voting during the previous month.
"We have had discussions over several weeks and fortunately, we have agreed a deal," PDP chief Mehbooba Mufti told reporters.
Ms Mufti, who appeared alongside BJP chief Amit Shah, said her father and PDP candidate for chief minister Mufti Mohammad Sayeed would soon meet Prime Minister Narendra Modi. The details of the agreement would be shared after that, she said.
Indian media reports, quoting sources, say Mr Sayeed is expected to be sworn in as chief minister on 1 March.
The disputed Kashmir region is claimed by both India and Pakistan.
It has been a flashpoint for more than 60 years and the rivals have fought two wars over the region.
The politics of Kashmir has long been dominated by the PDP and another regional party, the National Conference.
The BJP has never been a serious contender in the predominantly Muslim Kashmir valley, given its hard-line views on the state's relationship with India.
But in the run-up to the assembly elections Prime Minister Modi - who won national elections in May - campaigned extensively in the Hindu majority Jammu region and other parts of Kashmir, promising to bring jobs and development.