<?xml version="1.0" encoding="UTF-8"?><edgarSubmission xmlns="http://www.sec.gov/edgar/ownership" xmlns:ns2="http://www.sec.gov/edgar/common">
    <headerData>
        <submissionType>144</submissionType>
        <filerInfo>
            <filer>
                <filerCredentials>
                    <cik>0001635188</cik>
                    <ccc>XXXXXXXX</ccc>
                </filerCredentials>
            </filer>
            <liveTestFlag>LIVE</liveTestFlag>



        </filerInfo>
    </headerData>
    <formData>
        <issuerInfo>
            <issuerCik>0000876437</issuerCik>
            <issuerName>MGIC INVESTMENT CORPORATION</issuerName>
            <secFileNumber>001-10816</secFileNumber>
            <issuerAddress>
                <ns2:street1>250 East Kilbourn Avenue</ns2:street1>
                <ns2:city>Milwaukee</ns2:city>
                <ns2:stateOrCountry>WI</ns2:stateOrCountry>
                <ns2:zipCode>53202</ns2:zipCode>
            </issuerAddress>
            <issuerContactPhone>414 347 6480</issuerContactPhone>
            <nameOfPersonForWhoseAccountTheSecuritiesAreToBeSold>HUGHES LIVING TRUST</nameOfPersonForWhoseAccountTheSecuritiesAreToBeSold>
            <relationshipsToIssuer>
                <relationshipToIssuer>Officer</relationshipToIssuer>
            </relationshipsToIssuer>
        </issuerInfo>
        <securitiesInformation>
            <securitiesClassTitle>Common</securitiesClassTitle>
            <brokerOrMarketmakerDetails>
                <name>Morgan Stanley Smith Barney LLC Executive Financial Services</name>
                <address>
                    <ns2:street1>1 New York Plaza</ns2:street1>
                    <ns2:street2>38th Floor</ns2:street2>
                    <ns2:city>New York</ns2:city>
                    <ns2:stateOrCountry>NY</ns2:stateOrCountry>
                    <ns2:zipCode>10004</ns2:zipCode>
                </address>
            </brokerOrMarketmakerDetails>
            <noOfUnitsSold>120000</noOfUnitsSold>
            <aggregateMarketValue>2165052.00</aggregateMarketValue>
            <noOfUnitsOutstanding>282320501</noOfUnitsOutstanding>
            <approxSaleDate>08/07/2023</approxSaleDate>
            <securitiesExchangeName>NYSE</securitiesExchangeName>
        </securitiesInformation>
        <securitiesToBeSold>
            <securitiesClassTitle>Common</securitiesClassTitle>
            <acquiredDate>02/28/2022</acquiredDate>
            <natureOfAcquisitionTransaction>Performance Stock Units</natureOfAcquisitionTransaction>
            <nameOfPersonfromWhomAcquired>Issuer</nameOfPersonfromWhomAcquired>
            <isGiftTransaction>N</isGiftTransaction>
            <amountOfSecuritiesAcquired>54060</amountOfSecuritiesAcquired>
            <paymentDate>02/28/2022</paymentDate>
            <natureOfPayment>Compensation</natureOfPayment>
        </securitiesToBeSold>
        <securitiesToBeSold>
            <securitiesClassTitle>Common</securitiesClassTitle>
            <acquiredDate>03/05/2019</acquiredDate>
            <natureOfAcquisitionTransaction>Performance Stock Units</natureOfAcquisitionTransaction>
            <nameOfPersonfromWhomAcquired>Issuer</nameOfPersonfromWhomAcquired>
            <isGiftTransaction>N</isGiftTransaction>
            <amountOfSecuritiesAcquired>4800</amountOfSecuritiesAcquired>
            <paymentDate>03/05/2019</paymentDate>
            <natureOfPayment>Compensation</natureOfPayment>
        </securitiesToBeSold>
        <securitiesToBeSold>
            <securitiesClassTitle>Common</securitiesClassTitle>
            <acquiredDate>03/04/2020</acquiredDate>
            <natureOfAcquisitionTransaction>Performance Stock Units</natureOfAcquisitionTransaction>
            <nameOfPersonfromWhomAcquired>Issuer</nameOfPersonfromWhomAcquired>
            <isGiftTransaction>N</isGiftTransaction>
            <amountOfSecuritiesAcquired>26824</amountOfSecuritiesAcquired>
            <paymentDate>03/04/2020</paymentDate>
            <natureOfPayment>Compensation</natureOfPayment>
        </securitiesToBeSold>
        <securitiesToBeSold>
            <securitiesClassTitle>Common</securitiesClassTitle>
            <acquiredDate>02/10/2018</acquiredDate>
            <natureOfAcquisitionTransaction>Performance Stock Units</natureOfAcquisitionTransaction>
            <nameOfPersonfromWhomAcquired>Issuer</nameOfPersonfromWhomAcquired>
            <isGiftTransaction>N</isGiftTransaction>
            <amountOfSecuritiesAcquired>4060</amountOfSecuritiesAcquired>
            <paymentDate>02/10/2018</paymentDate>
            <natureOfPayment>Compensation</natureOfPayment>
        </securitiesToBeSold>
        <securitiesToBeSold>
            <securitiesClassTitle>Common</securitiesClassTitle>
            <acquiredDate>03/05/2018</acquiredDate>
            <natureOfAcquisitionTransaction>Performance Stock Units</natureOfAcquisitionTransaction>
            <nameOfPersonfromWhomAcquired>Issuer</nameOfPersonfromWhomAcquired>
            <isGiftTransaction>N</isGiftTransaction>
            <amountOfSecuritiesAcquired>10381</amountOfSecuritiesAcquired>
            <paymentDate>03/05/2018</paymentDate>
            <natureOfPayment>Compensation</natureOfPayment>
        </securitiesToBeSold>
        <securitiesToBeSold>
            <securitiesClassTitle>Common</securitiesClassTitle>
            <acquiredDate>07/25/2022</acquiredDate>
            <natureOfAcquisitionTransaction>Time Vested Units</natureOfAcquisitionTransaction>
            <nameOfPersonfromWhomAcquired>Issuer</nameOfPersonfromWhomAcquired>
            <isGiftTransaction>N</isGiftTransaction>
            <amountOfSecuritiesAcquired>19875</amountOfSecuritiesAcquired>
            <paymentDate>07/25/2022</paymentDate>
            <natureOfPayment>Compensation</natureOfPayment>
        </securitiesToBeSold>
        <nothingToReportFlagOnSecuritiesSoldInPast3Months>N</nothingToReportFlagOnSecuritiesSoldInPast3Months>
        <securitiesSoldInPast3Months>
            <sellerDetails>
                <name>HUGHES LIVING TRUST</name>
                <address>
                    <ns2:street1>250 East Kilbourn Avenue</ns2:street1>
                    <ns2:city>Milwaukee</ns2:city>
                    <ns2:stateOrCountry>WI</ns2:stateOrCountry>
                    <ns2:zipCode>53202</ns2:zipCode>
                </address>
            </sellerDetails>
            <securitiesClassTitle>Common</securitiesClassTitle>
            <saleDate>05/10/2023</saleDate>
            <amountOfSecuritiesSold>20000</amountOfSecuritiesSold>
            <grossProceeds>294927.00</grossProceeds>
        </securitiesSoldInPast3Months>
        <noticeSignature>
            <noticeDate>08/07/2023</noticeDate>
            <planAdoptionDates/>
            <signature>/s/ James Jeffrey Hughes, As Trustee</signature>
        </noticeSignature>
    </formData>
</edgarSubmission>
[{"type": "144", "sequence": "1", "filename": "primary_doc.xml", "secsgml_size_bytes": 6919}]
144
0001635188
XXXXXXXX
LIVE
0000876437
MGIC INVESTMENT CORPORATION
001-10816
250 East Kilbourn Avenue
Milwaukee
WI
53202
414 347 6480
HUGHES LIVING TRUST
Officer
Common
Morgan Stanley Smith Barney LLC Executive Financial Services
1 New York Plaza
38th Floor
New York
NY
10004
120000
2165052.00
282320501
08/07/2023
NYSE
Common
02/28/2022
Performance Stock Units
Issuer
N
54060
02/28/2022
Compensation
Common
03/05/2019
Performance Stock Units
Issuer
N
4800
03/05/2019
Compensation
Common
03/04/2020
Performance Stock Units
Issuer
N
26824
03/04/2020
Compensation
Common
02/10/2018
Performance Stock Units
Issuer
N
4060
02/10/2018
Compensation
Common
03/05/2018
Performance Stock Units
Issuer
N
10381
03/05/2018
Compensation
Common
07/25/2022
Time Vested Units
Issuer
N
19875
07/25/2022
Compensation
N
HUGHES LIVING TRUST
250 East Kilbourn Avenue
Milwaukee
WI
53202
Common
05/10/2023
20000
294927.00
08/07/2023
/s/ James Jeffrey Hughes, As Trustee